<!-- 博客 - 页面布局 > 上中下 -->



<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=dark>
<!-- 博客 - 导航栏上方 -->


<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/blog/img/fluid.png">
  <link rel="icon" href="/blog/img/icon/dw.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="Memory">
  <meta name="keywords" content="">

  
    <meta name="description" content="🥪 基于自身实践，总结Nginx学习使用过程中的经验">
<meta property="og:type" content="article">
<meta property="og:title" content="Nginx 入门指南：理解、配置和优化">
<meta property="og:url" content="https://test.atomgit.net/blog/2023/06/22/Nginx%20%E5%85%A5%E9%97%A8%E6%8C%87%E5%8D%97%EF%BC%9A%E7%90%86%E8%A7%A3%E3%80%81%E9%85%8D%E7%BD%AE%E5%92%8C%E4%BC%98%E5%8C%96/index.html">
<meta property="og:site_name" content="Memory&#39;s blog">
<meta property="og:description" content="🥪 基于自身实践，总结Nginx学习使用过程中的经验">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://test.atomgit.net/blog/img/artical/sea3.jpg">
<meta property="article:published_time" content="2023-06-22T02:04:32.000Z">
<meta property="article:modified_time" content="2024-07-09T04:56:34.000Z">
<meta property="article:author" content="Memory">
<meta property="article:tag" content="经验">
<meta property="article:tag" content="Nginx">
<meta property="article:tag" content="Linux">
<meta property="article:tag" content="Node.js">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://test.atomgit.net/blog/img/artical/sea3.jpg">
  
  
  
  <title>Nginx 入门指南：理解、配置和优化 - Memory&#39;s blog</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/blog/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/blog/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/blog/css/highlight-dark.css" />
  



  
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css">



  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"test.atomgit.net","root":"/blog/","version":"1.9.4","typing":{"enable":true,"typeSpeed":100,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":false,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":true,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"appId":"T1hUHH9Ks1ggG9DBE3HgUPpV-gzGzoHsz","appKey":"XFkgzzvzNo3J3uNCbBiSOFKc","server_url":"https://t1huhh9k.lc-cn-n1-shared.com","path":"window.location.pathname","ignore_local":false}},"search_path":"/blog/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/blog/js/utils.js" ></script>
  <script  src="/blog/js/color-schema.js" ></script>
  

  

  

  

  

  

  

  



  
<meta name="generator" content="Hexo 5.4.2"></head>

<body>
  

  <header>
    <!-- 博客 - 导航栏上方 -->


<div class="header-inner" style="height: 100vh">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/blog/">
      <strong>Memory&#39;s blog</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/">
                <i class="iconfont icon-home-fill"></i>
                <span>首页</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/archives/">
                <i class="iconfont icon-archive-fill"></i>
                <span>归档</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/categories/">
                <i class="iconfont icon-category-fill"></i>
                <span>分类</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/tags/">
                <i class="iconfont icon-tags-fill"></i>
                <span>标签</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/about/">
                <i class="iconfont icon-user-fill"></i>
                <span>关于</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/links/">
                <i class="iconfont icon-link-fill"></i>
                <span>友链</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/playlist/">
                <i class="iconfont icon-music"></i>
                <span>音乐</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/Memos/">
                <i class="iconfont icon-comment "></i>
                <span>说说</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/App/">
                <i class="iconfont icon-mobile"></i>
                <span>咫尺</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item dropdown">
              <a class="nav-link dropdown-toggle" target="_self" href="javascript:;" role="button"
                 data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <i class="iconfont icon-books"></i>
                <span>青简</span>
              </a>
              <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                
                  
                  
                  
                  <a class="dropdown-item" target="_blank" rel="noopener" href="http://47.93.135.62:5230/explore">
                    <i class="iconfont icon-images"></i>
                    <span>碎念微光</span>
                  </a>
                
                  
                  
                  
                  <a class="dropdown-item" href="/blog/New/">
                    <i class="iconfont icon-bug"></i>
                    <span>匠册详析</span>
                  </a>
                
                  
                  
                  
                  <a class="dropdown-item" href="/blog/New/">
                    <i class="iconfont icon-xbox-fill"></i>
                    <span>窗景新编</span>
                  </a>
                
                  
                  
                  
                  <a class="dropdown-item" href="/blog/New/">
                    <i class="iconfont icon-steam"></i>
                    <span>戏码幕后</span>
                  </a>
                
                  
                  
                  
                  <a class="dropdown-item" href="/blog/New/">
                    <i class="iconfont icon-map"></i>
                    <span>他山随拾</span>
                  </a>
                
              </div>
            </li>
          
        
        
            <li class="nav-item" id="search-btn">
                <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalNotice" aria-label="Search">
                    <i class="iconfont icon-book"></i>
                    <span>公告</span>
                </a>
            </li>
            
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              <i class="iconfont icon-search"></i>
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
              <i class="iconfont icon-dark" id="color-toggle-icon"></i>
            </a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>
 
<div id="banner" class="banner" parallax=true
     style="background: url('/blog/img/artical/sea3.jpg') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">

    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">

        <div class="h2">
          
            <span id="subtitle" data-typed-text="Nginx 入门指南：理解、配置和优化"></span>
          
        </div>


        
          <!-- 文章页面 - 顶部信息 -->

<div class="mt-3">
  
  <span class="post-meta mr-2">
    <i class="iconfont icon-author" aria-hidden="true"></i>
    Memory
  </span>
   
  <span class="post-meta">
    <i class="iconfont icon-date-fill" aria-hidden="true"></i>
    <time datetime="2023-06-22 10:04" pubdate>
      2023年6月22日 上午
    </time>
  </span>
  
</div>

<div class="mt-1">
  
  <span class="post-meta mr-2">
    <i class="iconfont icon-chart"></i>
     17k 字 
  </span>
   
  <span class="post-meta mr-2">
    <i class="iconfont icon-clock-fill"></i>
       43 分钟 
  </span>
     
  <span
    id="leancloud-page-views-container"
    class="post-meta"
    style="display: none"
  >
    <i class="iconfont icon-eye" aria-hidden="true"></i>
    <span id="leancloud-page-views"></span> 次
  </span>

    
</div>


        

        <!-- 添加网站运行时间 -->
        <div class="footer-content" style="background-color: transparent;">
          <div>
            <span id="timeDate"></span>
            <span id="times"></span>
            <script>
            var now = new Date();
            function createtime(){
                var grt= new Date("03/07/2023 00:00:00");//此处修改你的建站时间或者网站上线时间
                now.setTime(now.getTime()+250);
                days = (now - grt ) / 1000 / 60 / 60 / 24;
                dnum = Math.floor(days);
                hours = (now - grt ) / 1000 / 60 / 60 - (24 * dnum);
                hnum = Math.floor(hours);
                if(String(hnum).length ==1 ){
                    hnum = "0" + hnum;
                }
                minutes = (now - grt ) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum);
                mnum = Math.floor(minutes);
                if(String(mnum).length ==1 ){
                          mnum = "0" + mnum;
                }
                seconds = (now - grt ) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum);
                snum = Math.round(seconds);
                if(String(snum).length ==1 ){
                          snum = "0" + snum;
                }
                document.getElementById("timeDate").innerHTML = "🚀 &nbsp"+dnum+"&nbsp天";  //此次自定义显示内容
                document.getElementById("times").innerHTML = hnum + "&nbsp小时&nbsp" + mnum + "&nbsp分&nbsp" + snum + "&nbsp秒";
            }  

            if (!window.location.href.includes('/20')) {  
            setInterval("createtime()", 250);  // 只有当URL不包含'specific-page'时，才调用createtime  
            }//此次自定义显示内容
            </script>
          </div>
        </div>

      </div>
      
        <div class="scroll-down-bar">
          <i class="iconfont icon-arrowdown"></i>
        </div>
      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      <!-- 文章页  -->


<div class="container-fluid nopadding-x">

  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar category-bar" style="margin-right: -1rem">
    <!-- 文章页面 - 左边栏所属分类 -->
  

<!-- 文章页 - 文章分类 -->





<div class="category-list">
  
  
    
    
    
    <div class="category row nomargin-x">
      <a class="category-item 
          list-group-item category-item-action col-10 col-md-11 col-xm-11" title="代码锋芒"
        id="heading-843238cb7c4b39b52e95311733ff6da6" role="tab" data-toggle="collapse" href="#collapse-843238cb7c4b39b52e95311733ff6da6"
        aria-expanded="true"
      >
        代码锋芒
        <span class="list-group-count">(31)</span>
        <i class="iconfont icon-arrowright"></i>
      </a>
      
      <div class="category-collapse collapse show" id="collapse-843238cb7c4b39b52e95311733ff6da6"
           role="tabpanel" aria-labelledby="heading-843238cb7c4b39b52e95311733ff6da6">
        
        
          
          
  <div class="category-post-list">
    
    
      
      
        <a href="/blog/2023/03/19/MySQL%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE/" title="MySQL安装配置"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">MySQL安装配置</span>
        </a>
      
    
      
      
        <a href="/blog/2023/03/22/MySQL%E4%BB%8E%E5%85%A5%E9%97%A8%E5%88%B0%E5%85%A5%E5%9C%9F/" title="MySQL从入门到入土"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">MySQL从入门到入土</span>
        </a>
      
    
      
      
        <a href="/blog/2023/04/09/Java%E6%B3%9B%E5%9E%8B%E7%9A%84%E7%90%86%E8%A7%A3/" title="Java泛型：赋予灵活性的利器"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">Java泛型：赋予灵活性的利器</span>
        </a>
      
    
      
      
        <a href="/blog/2023/05/21/%E6%8E%A2%E7%B4%A2%20Python%20%E7%88%AC%E8%99%AB%E7%9A%84%E6%97%A0%E9%99%90%E5%8F%AF%E8%83%BD%E6%80%A7%EF%BC%9A%E5%9F%BA%E7%A1%80%E4%B8%8E%E5%BA%94%E7%94%A8/" title="探索Python爬虫的无限可能性：基础与应用"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">探索Python爬虫的无限可能性：基础与应用</span>
        </a>
      
    
      
      
        <a href="/blog/2023/06/03/%E4%BB%8E%E9%9B%B6%E5%BC%80%E5%A7%8B%E7%9A%84%20JavaWeb%20%E4%B9%8B%E6%97%85/" title="从零开始的 JavaWeb 之旅"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">从零开始的 JavaWeb 之旅</span>
        </a>
      
    
      
      
        <a href="/blog/2023/06/10/%E6%95%B0%E6%8D%AE%E5%BA%93-%E5%AE%8C%E6%95%B4%E6%80%A7%E7%BA%A6%E6%9D%9F/" title="数据库-完整性约束"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">数据库-完整性约束</span>
        </a>
      
    
      
      
        <a href="/blog/2023/06/24/%E4%BD%BF%E7%94%A8%20JSP%20%E6%9E%84%E5%BB%BA%20JavaWeb%20%E9%A1%B9%E7%9B%AE-%E4%BB%A5%E6%95%B0%E6%8D%AE%E5%BA%93%E5%A4%A7%E4%BD%9C%E4%B8%9A%E4%B8%BA%E4%BE%8B/" title="使用JSP构建JavaWeb项目--以数据库大作业为例"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">使用JSP构建JavaWeb项目--以数据库大作业为例</span>
        </a>
      
    
      
      
        <a href="/blog/2023/07/06/%E6%89%93%E9%80%A0%E6%B5%81%E7%95%85%E7%BC%96%E7%A0%81%E4%B9%8B%E6%97%85%EF%BC%9AIntelliJ%20IDEA%20%E7%9A%84%E9%AB%98%E6%95%88%E4%BD%BF%E7%94%A8%E6%8A%80%E5%B7%A7%E4%B8%8E%E5%B7%A5%E4%BD%9C%E6%B5%81%E7%A8%8B%E4%BC%98%E5%8C%96/" title="打造流畅编码之旅：IntelliJ IDEA 的高效使用技巧与工作流程优化"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">打造流畅编码之旅：IntelliJ IDEA 的高效使用技巧与工作流程优化</span>
        </a>
      
    
      
      
        <a href="/blog/2023/07/06/%E5%87%A4%E5%87%B0%E6%B6%85%E6%A7%83%EF%BC%9ASpring%20Boot%20%E5%BC%80%E5%8F%91%E4%B9%8B%E8%B7%AF%E4%B8%8A%E7%9A%84%E5%9D%8E%E5%9D%B7%E4%B8%8E%E6%88%90%E9%95%BF/" title="凤凰涅槃：Spring Boot 开发之路上的坎坷与成长"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">凤凰涅槃：Spring Boot 开发之路上的坎坷与成长</span>
        </a>
      
    
      
      
        <a href="/blog/2023/07/11/%E4%BB%8EIP%E5%88%B0Ping%E5%91%BD%E4%BB%A4%EF%BC%9A%E4%BA%86%E8%A7%A3%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C%E8%BF%9E%E6%8E%A5%E7%9A%84%E5%9F%BA%E7%A1%80/" title="从IP到Ping命令：了解计算机网络连接的基础"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">从IP到Ping命令：了解计算机网络连接的基础</span>
        </a>
      
    
      
      
        <a href="/blog/categories/%E4%BB%A3%E7%A0%81%E9%94%8B%E8%8A%92/" class="list-group-item list-group-item-action">
          <span class="category-post">More...</span>
        </a>
        
  </div>

          
  
    
    
    
    <div class="category-sub row nomargin-x">
      <a class="category-subitem collapsed
          list-group-item category-item-action col-10 col-md-11 col-xm-11" title="职路星火"
        id="heading-59c550454d1ecf67a2ead26a1c46d14b" role="tab" data-toggle="collapse" href="#collapse-59c550454d1ecf67a2ead26a1c46d14b"
        aria-expanded="false"
      >
        职路星火
        <span class="list-group-count">(2)</span>
        <i class="iconfont icon-arrowright"></i>
      </a>
      
      <div class="category-collapse collapse " id="collapse-59c550454d1ecf67a2ead26a1c46d14b"
           role="tabpanel" aria-labelledby="heading-59c550454d1ecf67a2ead26a1c46d14b">
        
        
          
  <div class="category-post-list">
    
    
      
      
        <a href="/blog/2024/03/07/%E7%A0%BA%E5%89%91%E5%87%BA%E9%9E%98%EF%BC%9A%E6%88%91%E7%9A%84%E8%BD%AF%E4%BB%B6%E5%B7%A5%E7%A8%8B%E5%B8%88%E6%B1%82%E8%81%8C%E4%B9%8B%E6%97%85/" title="砺剑出鞘：我的软件工程师求职之旅"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">砺剑出鞘：我的软件工程师求职之旅</span>
        </a>
      
    
      
      
        <a href="/blog/2024/04/16/%E6%8B%A8%E4%BA%91%E8%A7%81%E6%97%A5%EF%BC%9A%E8%81%8C%E5%9C%BA%E7%94%9F%E6%B4%BB%E7%9A%84%E7%82%B9%E6%BB%B4%E8%AE%B0%E5%BD%95/" title="拨云见日：职场生活的点滴记录"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">拨云见日：职场生活的点滴记录</span>
        </a>
      
    
  </div>

        
      </div>
    </div>
  
    
    
    
    <div class="category-sub row nomargin-x">
      <a class="category-subitem 
          list-group-item category-item-action col-10 col-md-11 col-xm-11" title="部署之道"
        id="heading-36acf247b1a64f4bbe423776a392cfde" role="tab" data-toggle="collapse" href="#collapse-36acf247b1a64f4bbe423776a392cfde"
        aria-expanded="true"
      >
        部署之道
        <span class="list-group-count">(5)</span>
        <i class="iconfont icon-arrowright"></i>
      </a>
      
      <div class="category-collapse collapse show" id="collapse-36acf247b1a64f4bbe423776a392cfde"
           role="tabpanel" aria-labelledby="heading-36acf247b1a64f4bbe423776a392cfde">
        
        
          
          
  <div class="category-post-list">
    
    
      
      
        <a href="/blog/2023/06/22/Nginx%20%E5%85%A5%E9%97%A8%E6%8C%87%E5%8D%97%EF%BC%9A%E7%90%86%E8%A7%A3%E3%80%81%E9%85%8D%E7%BD%AE%E5%92%8C%E4%BC%98%E5%8C%96/" title="Nginx 入门指南：理解、配置和优化"
           class="list-group-item list-group-item-action
           active">
          <span class="category-post">Nginx 入门指南：理解、配置和优化</span>
        </a>
      
    
      
      
        <a href="/blog/2023/07/11/Docker%20%E5%85%A5%E9%97%A8%E4%B8%8E%E5%AE%9E%E8%B7%B5%EF%BC%9A%E5%BF%AB%E9%80%9F%E6%89%93%E9%80%A0%E9%AB%98%E6%95%88%E7%BD%91%E7%AB%99%E9%83%A8%E7%BD%B2%E7%8E%AF%E5%A2%83/" title="Docker入门与实践：快速打造高效网站部署环境"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">Docker入门与实践：快速打造高效网站部署环境</span>
        </a>
      
    
      
      
        <a href="/blog/2023/08/17/%E6%B7%B1%E5%85%A5%E7%90%86%E8%A7%A3%20API%20%E7%BD%91%E5%85%B3%EF%BC%9A%E5%8E%9F%E7%90%86%E3%80%81%E5%8A%9F%E8%83%BD%E5%92%8C%E7%94%A8%E9%80%94/" title="深入理解 API 网关：原理、功能和用途"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">深入理解 API 网关：原理、功能和用途</span>
        </a>
      
    
  </div>

          
  
    
    
    
    <div class="category-sub row nomargin-x">
      <a class="category-subitem collapsed
          list-group-item category-item-action col-10 col-md-11 col-xm-11" title="职路星火"
        id="heading-59c550454d1ecf67a2ead26a1c46d14b" role="tab" data-toggle="collapse" href="#collapse-59c550454d1ecf67a2ead26a1c46d14b"
        aria-expanded="false"
      >
        职路星火
        <span class="list-group-count">(2)</span>
        <i class="iconfont icon-arrowright"></i>
      </a>
      
      <div class="category-collapse collapse " id="collapse-59c550454d1ecf67a2ead26a1c46d14b"
           role="tabpanel" aria-labelledby="heading-59c550454d1ecf67a2ead26a1c46d14b">
        
        
          
  <div class="category-post-list">
    
    
      
      
        <a href="/blog/2024/12/16/%E6%BC%AB%E6%BC%AB%E5%BE%81%E9%80%94%EF%BC%9A%E7%AD%91%E6%A2%A6%E4%BA%8E%E8%81%8C%E5%9C%BA%E9%A3%8E%E9%9B%A8%EF%BC%8C%E5%90%9F%E5%92%8F%E4%BA%8E%E6%97%A5%E5%B8%B8%E8%AF%97%E6%84%8F/" title="漫漫征途：筑梦于职场风雨，吟咏于日常诗意"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">漫漫征途：筑梦于职场风雨，吟咏于日常诗意</span>
        </a>
      
    
      
      
        <a href="/blog/2025/10/23/%E4%BF%9D%E9%A9%BE%E6%8A%A4%E8%88%AA%E2%80%94%E2%80%94%E5%90%8E%E5%8F%B0%E8%BF%90%E7%BB%B4%E8%A7%86%E8%A7%92%E4%B8%8B%E7%9A%84%E9%AB%98%E9%80%9F%E5%85%AC%E8%B7%AF%E2%80%9C%E7%94%9F%E5%91%BD%E7%BA%BF%E2%80%9D/" title="保驾护航——后台运维视角下的高速公路“生命线”"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">保驾护航——后台运维视角下的高速公路“生命线”</span>
        </a>
      
    
  </div>

        
      </div>
    </div>
  
        
      </div>
    </div>
  
    
    
    
    <div class="category-sub row nomargin-x">
      <a class="category-subitem collapsed
          list-group-item category-item-action col-10 col-md-11 col-xm-11" title="项目志录"
        id="heading-005e56101bc2a873707cb4461a70ded8" role="tab" data-toggle="collapse" href="#collapse-005e56101bc2a873707cb4461a70ded8"
        aria-expanded="false"
      >
        项目志录
        <span class="list-group-count">(1)</span>
        <i class="iconfont icon-arrowright"></i>
      </a>
      
      <div class="category-collapse collapse " id="collapse-005e56101bc2a873707cb4461a70ded8"
           role="tabpanel" aria-labelledby="heading-005e56101bc2a873707cb4461a70ded8">
        
        
          
  <div class="category-post-list">
    
    
      
      
        <a href="/blog/2023/07/30/%E5%B0%8F%E7%A8%8B%E5%BA%8F%E5%BC%80%E5%8F%91%E7%BB%8F%E9%AA%8C%E5%88%86%E4%BA%AB%EF%BC%9A%E8%B8%A9%E5%9D%91%E6%8C%87%E5%8D%97%E4%B8%8E%E6%8A%80%E5%B7%A7%E6%80%BB%E7%BB%93/" title="小程序开发经验分享：踩坑指南与技巧总结"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">小程序开发经验分享：踩坑指南与技巧总结</span>
        </a>
      
    
  </div>

        
      </div>
    </div>
  
        
      </div>
    </div>
  
</div>

  </aside>


    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">Nginx 入门指南：理解、配置和优化</h1>
            
              <p class="note note-success">
                
                  
                    本文最后更新于：1 年前
                  
                
              </p>
            
            
              <div class="markdown-body">
                
                <h1 id="破冰"><a href="#破冰" class="headerlink" title="破冰"></a>破冰</h1><blockquote>
<p>🥣 推荐阅读：</p>
<ul>
<li><h5 id="67-条消息-Nginx-目录结构与配置文件详解nginx-目录不会调制解调的猫的博客-CSDN-博客-（2023-12-15-午）"><a href="#67-条消息-Nginx-目录结构与配置文件详解nginx-目录不会调制解调的猫的博客-CSDN-博客-（2023-12-15-午）" class="headerlink" title="(67 条消息) Nginx - 目录结构与配置文件详解nginx 目录不会调制解调的猫的博客-CSDN 博客 （2023/12/15 午）"></a><a target="_blank" rel="noopener" href="https://blog.csdn.net/Trollz/article/details/126525238">(67 条消息) Nginx - 目录结构与配置文件详解<em>nginx 目录</em>不会调制解调的猫的博客-CSDN 博客</a> （2023/12/15 午）</h5></li>
<li><h5 id="Nginx-的配置文件详解-KuangStudy-文章"><a href="#Nginx-的配置文件详解-KuangStudy-文章" class="headerlink" title="Nginx 的配置文件详解-KuangStudy-文章"></a><a target="_blank" rel="noopener" href="https://www.kuangstudy.com/bbs/1619965646882693121">Nginx 的配置文件详解-KuangStudy-文章</a></h5></li>
</ul>
</blockquote>
<h2 id="Nginx-是什么"><a href="#Nginx-是什么" class="headerlink" title="Nginx 是什么"></a>Nginx 是什么</h2><ul>
<li><h5 id="官⽅解析-："><a href="#官⽅解析-：" class="headerlink" title="官⽅解析 ："></a>官⽅解析 ：</h5></li>
</ul>
<figure class="highlight llvm"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs llvm">Nginx（发⾳为“engine-<span class="hljs-keyword">x</span>”）是⼀个⾼性能的开源 Web 服务器和反向代理服务器，可以处理⼤ 量的并发连接和请求。它使⽤事件驱动的异步架构和多线程设计，可以⾼效地处理并发请求， 同时也⽀持反向代理、负载均衡、动态HTTP缓存、SSL/TLS终⽌、基于模块的扩展等功能。<br></code></pre></td></tr></table></figure>

<ul>
<li><p>Nginx 的应⽤场景⾮常⼴泛，以下是其中的⼏个：</p>
</li>
<li><p><strong>Web 服务器：</strong>Nginx 可以作为 HTTP 服务器，处理并发的静态请求和动态请求，并且可 以⽀持负载均衡和缓存，为⽹站提供⾼性能和⾼可⽤性。</p>
</li>
<li><p><strong>反向代理服务器：</strong>Nginx 可以作为反向代理服务器，接收客户端请求并将其转发到后端服 务器，同时也可以⽀持负载均衡和缓存。</p>
</li>
<li><p><strong>邮件代理服务器：</strong>Nginx 可以作为邮件代理服务器，⽀持 POP3、IMAP 和 SMTP 协议， 并且可以⽀持 SSL/TLS 加密和反垃圾邮件功能。</p>
</li>
<li><p><strong>流媒体服务器：</strong>Nginx 可以作为流媒体服务器，⽀持 RTMP、HLS 和 DASH 协议，可以 ⽤于实现直播、点播和视频-on-demand（VoD）等场景。</p>
</li>
<li><h5 id="总之，Nginx-具有⾼性能、可扩展性和可靠性等特点，被⼴泛应⽤于⼤型⽹站、互联⽹公司、-云计算、视频流媒体、游戏等领域"><a href="#总之，Nginx-具有⾼性能、可扩展性和可靠性等特点，被⼴泛应⽤于⼤型⽹站、互联⽹公司、-云计算、视频流媒体、游戏等领域" class="headerlink" title="总之，Nginx 具有⾼性能、可扩展性和可靠性等特点，被⼴泛应⽤于⼤型⽹站、互联⽹公司、 云计算、视频流媒体、游戏等领域"></a>总之，Nginx 具有⾼性能、可扩展性和可靠性等特点，被⼴泛应⽤于⼤型⽹站、互联⽹公司、 云计算、视频流媒体、游戏等领域</h5></li>
</ul>
<h1 id="思维碰撞"><a href="#思维碰撞" class="headerlink" title="思维碰撞"></a>思维碰撞</h1><h2 id="Nginx-部署静态站点（2024-最新）"><a href="#Nginx-部署静态站点（2024-最新）" class="headerlink" title="Nginx 部署静态站点（2024 最新）"></a>Nginx 部署静态站点（2024 最新）</h2><blockquote>
<p>2024 年 6 月 3 日</p>
</blockquote>
<h3 id="Nginx-安装"><a href="#Nginx-安装" class="headerlink" title="Nginx 安装"></a>Nginx 安装</h3><p>这里推荐宝塔面板安装，一条龙完成：</p>
<p>安装宝塔面板：</p>
<p>访问宝塔面板：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">/etc/init.d/bt default	<span class="hljs-comment"># 获取宝塔面板账号密码</span><br></code></pre></td></tr></table></figure>

<p><img src="http://blog.memory-life.xyz/image-20240603091818493.png" alt="image-20240603091818493"></p>
<p>一键编译安装：</p>
<p><img src="http://blog.memory-life.xyz/image-20240603091901391.png" alt="image-20240603091901391"></p>
<p>记得查看默认访问端口，宝塔面板安装下的 nginx 默认是 888 端口，云服务器也要开放 888 端口</p>
<p>搞完了直接访问就行。</p>
<h3 id="尝试部署静态页面"><a href="#尝试部署静态页面" class="headerlink" title="尝试部署静态页面"></a>尝试部署静态页面</h3><p><strong>接下来就是四十八小时时间里的踩坑记录</strong>，仅供参照：</p>
<blockquote>
<p>2024 年 6 月 1 日</p>
</blockquote>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/m0_49000161/article/details/132415997">【一篇学会】Nginx 静态资源部署保姆级教程_nginx 部署静态资源-CSDN 博客</a></p>
<p><a target="_blank" rel="noopener" href="https://cloud.tencent.com/developer/article/2363273">Nginx 静态资源服务的配置-腾讯云开发者社区-腾讯云 (tencent.com)</a></p>
<figure class="highlight ada"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs ada">MIME 类型<br>MIME（多用途互联网邮件扩展类型）是一种标准化的方式，用于表示文档、文件或字节流的性质和格式。它在IETF RFC <span class="hljs-number">6838</span>中进行了定义和标准化，由互联网号码分配机构（IANA）负责跟踪所有官方MIME类型。MIME类型由两部分组成：类型（<span class="hljs-keyword">type</span>）和子类型（<span class="hljs-keyword">subtype</span>），它们之间用斜杠（/）分隔，不允许空格存在。MIME类型对大小写不敏感，但传统写法都是小写<br></code></pre></td></tr></table></figure>

<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/m0_62231324/article/details/132524647">Nginx 配置文件详解-CSDN 博客</a></p>
<p><a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1Ku411p73U/?spm_id_from=333.337.search-card.all.click&vd_source=4314e5bd742ea904c9675af8a6b4b07e">8 分钟用 Nginx 搭建一个自己的网站_哔哩哔哩_bilibili</a></p>
<p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/WindSnowLi/p/16998206.html">Linux 使用 nginx 部署静态网页 - WindSnowLi - 博客园 (cnblogs.com)</a></p>
<p><a target="_blank" rel="noopener" href="https://www.jarcheng.top/blog/knowledge/website/#nginx%E9%85%8D%E7%BD%AE">手把手教你搭建静态/博客网站 | 起凡 Code 闲聊 (jarcheng.top)</a></p>
<p>跟着网上的教程搞了一下午，就是部署不了静态页面，甚至连访问 Nginx 本身都好像有问题，搞不明白，实在是搞不明白。</p>
<p>不管怎么说，今晚我就死磕这个 Nginx 了，多少个晚上都像现在这样把它放过，所以到现在都没有学习完成过 Nginx。</p>
<blockquote>
<p>2024 年 6 月 2 日</p>
</blockquote>
<p>[root@iZ2ze4yceifsrmdejokfymZ ~]# nginx<br>nginx: [emerg] bind() to 0.0.0.0:7010 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:888 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:7071 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:7001 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:7020 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:7010 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:888 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:7071 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:7001 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:7020 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:7010 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:888 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:7071 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:7001 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:7020 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:7010 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:888 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:7071 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:7001 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:7020 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:7010 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:888 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:7071 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:7001 failed (98: Unknown error)<br>nginx: [emerg] bind() to 0.0.0.0:7020 failed (98: Unknown error)<br>nginx: [emerg] still could not bind()</p>
<p><img src="http://blog.memory-life.xyz/image-20240602182928144.png" alt="image-20240602182928144"></p>
<p>[Nginx 重启时提示”nginx: <a target="_blank" rel="noopener" href="https://www.8a.hk/index.php/news/content/2898.html">emerg] bind() to 0.0.0.0”解决方法 - 八艾云 (8a.hk)</a></p>
<p><img src="http://blog.memory-life.xyz/image-20240602185109255.png" alt="image-20240602185109255"></p>
<p><a target="_blank" rel="noopener" href="https://www.code-nav.cn/post/1652294765397454849#heading-7">极简 Nginx 学习 + 使用，点到为止 - 编程导航文章 (code-nav.cn)</a></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><code class="hljs bash">要查看当前用户是否是管理员（在Unix和Linux系统中通常指的是root用户，或在Windows系统中指的是具有管理员权限的用户），你可以使用不同的方法，具体取决于你使用的操作系统。<br><br>在Unix/Linux系统中：<br><br>查看当前用户名：<br>在终端中输入 <span class="hljs-built_in">whoami</span> 命令。如果输出是 root，那么你就是管理员。<br>查看用户ID：<br>输入 <span class="hljs-built_in">id</span> 命令。如果UID（用户ID）是0，那么你就是root用户。<br>查看/etc/passwd文件（需要root权限）：<br>你可以查看/etc/passwd文件，但通常需要root权限来查看完整的文件内容。使用<span class="hljs-built_in">cat</span> /etc/passwd命令，并查找以root:开头的行。<br>在Windows系统中：<br><br>打开命令提示符：<br>按下Win + R，输入cmd，然后按下Enter键。<br>检查用户账户控制（UAC）提示：<br>当你尝试执行需要管理员权限的任务时，Windows通常会显示一个UAC提示。如果你没有看到这些提示，那么你可能不是以管理员身份登录的。<br>检查用户账户：<br>在“控制面板”中，你可以查看用户账户并检查你的账户是否有管理员权限。<br>使用net user命令（在命令提示符中）：<br>输入net user命令并查看输出。找到你的用户名，并检查它是否列出了管理员组（例如，“Administrators”组）。<br>运行<span class="hljs-built_in">whoami</span> /groups（在命令提示符中）：<br>这个命令将列出你当前用户所属的所有组。如果你看到“S-1-5-32-544”（管理员组的SID），那么你就是管理员。<br>使用PowerShell：<br>在PowerShell中，你可以使用[System.Security.Principal.WindowsIdentity]::GetCurrent().Groups命令来查看当前用户所属的组。然后，你可以检查输出中是否包含管理员组。<br>请注意，成为管理员用户（特别是在Unix/Linux中的root用户）具有极大的权限，可以执行系统范围内的更改。因此，请务必谨慎行事，并在需要时始终考虑使用具有较低权限的用户账户。<br></code></pre></td></tr></table></figure>

<p>netstat -tulnp | grep 7010</p>
<p>我已经尝试了所有方法，查看冲突端口号、关闭防火墙，修改执行用户，更改文件目录权限，根本部署不了静态页面</p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/2301_79099416/article/details/139116845">3 分钟搞懂阿里云服务器安装 Nginx 并配置静态访问页面_阿里云服务器如何安装 nginx-CSDN 博客</a></p>
<p><img src="http://blog.memory-life.xyz/image-20240602213424584.png" alt="image-20240602213424584"></p>
<p>[nginx: <a target="_blank" rel="noopener" href="https://blog.csdn.net/gphjl/article/details/42104639">error] invalid PID number “” in “/usr/local/webserver/nginx/logs/nginx.pid”-CSDN 博客</a></p>
<figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs awk">nginx -c <span class="hljs-regexp">/www/</span>server<span class="hljs-regexp">/nginx/</span>conf/nginx.conf<br></code></pre></td></tr></table></figure>

<p>搞不定，一夜回到解放前。</p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/underworld33/article/details/129140664">Nginx 部署与静态 html_nginx 部署 html-CSDN 博客</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/debimeng/article/details/89005546">【Linux 报错】登陆 mysql 用户报错 This account is currently not available._mysql:x:1001:-CSDN 博客</a></p>
<blockquote>
<p>2024 年 6 月 3 日</p>
</blockquote>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/Keep__Me/article/details/137924903">Linux 实现 Nginx 的安装与部署并实现 html 静态资源访问_linux nginx html-CSDN 博客</a></p>
<figure class="highlight ini"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><code class="hljs ini"><span class="hljs-section">[nginx-stable]</span><br><span class="hljs-attr">name</span>=nginx stable repo<br><span class="hljs-attr">baseurl</span>=http://nginx.org/packages/centos/<span class="hljs-number">7</span>/<span class="hljs-variable">$basearch</span>/<br><span class="hljs-attr">gpgcheck</span>=<span class="hljs-number">1</span><br><span class="hljs-attr">enabled</span>=<span class="hljs-number">1</span><br><span class="hljs-attr">gpgkey</span>=https://nginx.org/keys/nginx_signing.key<br><span class="hljs-attr">module_hotfixes</span>=<span class="hljs-literal">true</span><br><br><span class="hljs-section">[nginx-mainline]</span><br><span class="hljs-attr">name</span>=nginx mainline repo<br><span class="hljs-attr">baseurl</span>=http://nginx.org/packages/mainline/centos/<span class="hljs-number">7</span>/<span class="hljs-variable">$basearch</span>/<br><span class="hljs-attr">gpgcheck</span>=<span class="hljs-number">1</span><br><span class="hljs-attr">enabled</span>=<span class="hljs-number">0</span><br><span class="hljs-attr">gpgkey</span>=https://nginx.org/keys/nginx_signing.key<br><span class="hljs-attr">module_hotfixes</span>=<span class="hljs-literal">true</span><br></code></pre></td></tr></table></figure>

<figure class="highlight ada"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs ada">sudo yum clean <span class="hljs-keyword">all</span><br>sudo yum makecache<br></code></pre></td></tr></table></figure>

<p><img src="http://blog.memory-life.xyz/image-20240603080013103.png" alt="image-20240603080013103"></p>
<figure class="highlight gradle"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs gradle"><span class="hljs-keyword">grep</span> -r <span class="hljs-keyword">exclude</span> <span class="hljs-regexp">/etc/yum</span>.conf <span class="hljs-regexp">/etc/yum</span>.repos.d/<br></code></pre></td></tr></table></figure>

<p><img src="http://blog.memory-life.xyz/image-20240603075634506.png" alt="image-20240603075634506"></p>
<figure class="highlight cmake"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs cmake">sudo yum <span class="hljs-keyword">install</span> nginx<br></code></pre></td></tr></table></figure>

<p><img src="http://blog.memory-life.xyz/image-20240603080124927.png" alt="image-20240603080124927"></p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs powershell">systemctl <span class="hljs-built_in">start</span> nginx  <span class="hljs-comment">#启动nginx服务器</span><br><span class="hljs-built_in">ps</span> <span class="hljs-literal">-aux</span> | grep nginx  <span class="hljs-comment">#查看nginx进程</span><br></code></pre></td></tr></table></figure>

<figure class="highlight maxima"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs maxima">systemctl <span class="hljs-built_in">restart</span> nginx<br>systemctl <span class="hljs-built_in">status</span> nginx<br></code></pre></td></tr></table></figure>

<p><img src="http://blog.memory-life.xyz/image-20240603080537255.png" alt="image-20240603080537255"></p>
<figure class="highlight vim"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs vim"><span class="hljs-keyword">find</span> / -name nginx.<span class="hljs-keyword">conf</span><br><br><span class="hljs-keyword">cd</span> ..<br><span class="hljs-keyword">find</span> -name nginx.<span class="hljs-keyword">conf</span><br></code></pre></td></tr></table></figure>

<p><img src="http://blog.memory-life.xyz/image-20240603081030466.png" alt="image-20240603081030466"></p>
<figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br></pre></td><td class="code"><pre><code class="hljs nginx"><span class="hljs-section">server</span> &#123;<br>    <span class="hljs-attribute">listen</span>       <span class="hljs-number">80</span>;<br>    <span class="hljs-attribute">server_name</span>  localhost;<br><br>    <span class="hljs-comment">#access_log  /var/log/nginx/host.access.log  main;</span><br><br>    <span class="hljs-attribute">autoindex</span> <span class="hljs-literal">on</span>;<br>    <span class="hljs-section">location</span> / &#123;<br>        <span class="hljs-attribute">root</span>   /usr/share/nginx/html;<br>        <span class="hljs-attribute">index</span>  index.html index.htm;<br>    &#125;<br><br>    <span class="hljs-comment">#error_page  404              /404.html;</span><br><br>    <span class="hljs-comment"># redirect server error pages to the static page /50x.html</span><br>    <span class="hljs-comment">#</span><br>    <span class="hljs-attribute">error_page</span>   <span class="hljs-number">500</span> <span class="hljs-number">502</span> <span class="hljs-number">503</span> <span class="hljs-number">504</span>  /50x.html;<br>    <span class="hljs-section">location</span> = /50x.html &#123;<br>        <span class="hljs-attribute">root</span>   /usr/share/nginx/html;<br>    &#125;<br><br>    <span class="hljs-comment"># proxy the PHP scripts to Apache listening on 127.0.0.1:80</span><br>    <span class="hljs-comment">#</span><br>    <span class="hljs-comment">#location ~ \.php$ &#123;</span><br>    <span class="hljs-comment">#    proxy_pass   http://127.0.0.1;</span><br>    <span class="hljs-comment">#&#125;</span><br><br>    <span class="hljs-comment"># pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000</span><br>    <span class="hljs-comment">#</span><br>    <span class="hljs-comment">#location ~ \.php$ &#123;</span><br>    <span class="hljs-comment">#    root           html;</span><br>    <span class="hljs-comment">#    fastcgi_pass   127.0.0.1:9000;</span><br>    <span class="hljs-comment">#    fastcgi_index  index.php;</span><br>    <span class="hljs-comment">#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;</span><br>    <span class="hljs-comment">#    include        fastcgi_params;</span><br>    <span class="hljs-comment">#&#125;</span><br><br>    <span class="hljs-comment"># deny access to .htaccess files, if Apache&#x27;s document root</span><br>    <span class="hljs-comment"># concurs with nginx&#x27;s one</span><br>    <span class="hljs-comment">#</span><br>    <span class="hljs-comment">#location ~ /\.ht &#123;</span><br>    <span class="hljs-comment">#    deny  all;</span><br>    <span class="hljs-comment">#&#125;</span><br>&#125;<br></code></pre></td></tr></table></figure>

<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/nicolelili1/article/details/103381658">nginx 服务器搭建好但是浏览器却无法访问原因排查_nginx 配置好了 网站还是访问不了-CSDN 博客</a></p>
<p><img src="http://blog.memory-life.xyz/image-20240603084009334.png" alt="image-20240603084009334"></p>
<p>这几天里报错最恶心的还是这条：</p>
<figure class="highlight vbnet"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs vbnet"><span class="hljs-symbol">nginx:</span> [emerg] bind() <span class="hljs-keyword">to</span> <span class="hljs-number">0.0</span>.<span class="hljs-number">0.0</span>:<span class="hljs-number">7010</span> failed (<span class="hljs-number">98</span>: Unknown <span class="hljs-keyword">error</span>)<br></code></pre></td></tr></table></figure>

<p>最后是在宝塔面板卸载重装以后才解决的，现在也不知道什么原因。</p>
<p><strong>还是很有收获的，学到了许多其他新知识。</strong></p>
<blockquote>
<p>2024 年 6 月 4 日</p>
</blockquote>
<p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/tt212/p/17684371.html">linux 怎么快速卸载并安装 node 环境 - Jun_ct - 博客园 (cnblogs.com)</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_37450502/article/details/130959110">yum、apt-get、wget 的区别_yum wget-CSDN 博客</a></p>
<p><a target="_blank" rel="noopener" href="https://cloud.tencent.com/developer/article/2045120">wget、yum、rpm、apt-get 区别「建议收藏」-腾讯云开发者社区-腾讯云 (tencent.com)</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/angle_chen123/article/details/120675472">Linux curl 命令最全详解-CSDN 博客</a></p>
<p>云服务器部署静态博客站点，搞了一上午，代码推送不上去，Nginx 也起不来了。</p>
<p><a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/381967653">运维排查篇 | 访问 nginx 出现 403 错误 - 知乎 (zhihu.com)</a></p>
<p><img src="http://blog.memory-life.xyz/image-20240604110147986.png" alt="image-20240604110147986"></p>
<p><img src="http://blog.memory-life.xyz/image-20240604110649330.png" alt="image-20240604110649330"></p>
<p>过了一个小时再尝试，静态代码文件就能推送上去了。杀死已经启动的 Nginx 进程，也能成功启动 Nginx 了。</p>
<h3 id="问题解决"><a href="#问题解决" class="headerlink" title="问题解决"></a>问题解决</h3><blockquote>
<p>2024 年 6 月 3 日</p>
</blockquote>
<p>查看本实例的安全组，应用了哪个安全组规则：</p>
<p><img src="http://blog.memory-life.xyz/image-20240603090238565.png" alt="image-20240603090238565"></p>
<p><img src="http://blog.memory-life.xyz/image-20240603090310965.png" alt="image-20240603090310965"></p>
<p>以下这就是应用到的真正的安全组规则（<strong>注意上方地域选择</strong>）：</p>
<p><img src="http://blog.memory-life.xyz/image-20240603090138530.png" alt="image-20240603090138530"></p>
<p>这几天以来，一直选错了地域，搞另一个地域下的安全组规则。原来根本就没放开 80、7010、7020 端口：</p>
<p><img src="http://blog.memory-life.xyz/image-20240603090604067.png" alt="image-20240603090604067"></p>
<h3 id="重启失败"><a href="#重启失败" class="headerlink" title="重启失败"></a>重启失败</h3><blockquote>
<p>2024 年 6 月 4 日</p>
</blockquote>
<p><img src="http://blog.memory-life.xyz/image-20240604105639790.png" alt="image-20240604105639790"></p>
<p>这个报错直接杀死正在运行的 Nginx 进程就可以了。</p>
<h3 id="访问-403-错误"><a href="#访问-403-错误" class="headerlink" title="访问 403 错误"></a>访问 403 错误</h3><blockquote>
<p>2024 年 6 月 4 日</p>
</blockquote>
<p>🥣 推荐阅读：<a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/381967653">运维排查篇 | 访问 nginx 出现 403 错误 - 知乎 (zhihu.com)</a></p>
<h3 id="一条龙"><a href="#一条龙" class="headerlink" title="一条龙"></a>一条龙</h3><blockquote>
<p>2024 年 6 月 3 日</p>
</blockquote>
<p>🥣 安装 Nginx 并部署静态页面，看这篇博客：<a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/646239152">服务器——Nginx 安装及静态配置、部署 - 知乎 (zhihu.com)</a></p>
<p>🍚 解决 Nginx 访问失败问题，看这篇博客：<a target="_blank" rel="noopener" href="https://blog.csdn.net/nicolelili1/article/details/103381658">nginx 服务器搭建好但是浏览器却无法访问原因排查_nginx 配置好了 网站还是访问不了-CSDN 博客</a></p>
<figure class="highlight routeros"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs routeros">firewall-cmd <span class="hljs-attribute">--zone</span>=public <span class="hljs-attribute">--add-port</span>=8080/tcp --permanent<br></code></pre></td></tr></table></figure>

<figure class="highlight ada"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs ada">firewall-cmd <span class="hljs-comment">--reload</span><br></code></pre></td></tr></table></figure>

<p>使用 Nginx 部署 博客站点，看：</p>
<ul>
<li><a target="_blank" rel="noopener" href="https://www.cnblogs.com/cheyaoyao/p/17836522.html">使用 Hexo 搭建个人博客并部署到云服务器 - Cheyaoyao - 博客园 (cnblogs.com)</a></li>
<li><a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/381967653">运维排查篇 | 访问 nginx 出现 403 错误 - 知乎 (zhihu.com)</a></li>
</ul>
<h2 id="CPU-爆满"><a href="#CPU-爆满" class="headerlink" title="CPU 爆满"></a>CPU 爆满</h2><blockquote>
<p>2024 年 6 月 21 日</p>
</blockquote>
<p>最近一周云服务器 CPU 负载一直很高，经常在 80%左右，博客访问都卡的根本打不开。</p>
<p><img src="http://blog.memory-life.xyz/image-20240621090813896.png" alt="image-20240621090813896"></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/shark_chili3007/article/details/104096100">Nginx 性能优化_nginx cpu 负载高-CSDN 博客</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/tiny_du/article/details/119238948">清除 nginx 连接数 TIME_WAIT_nginx 连接数满了-CSDN 博客</a></p>
<p><img src="http://blog.memory-life.xyz/image-20240621082513343.png" alt="image-20240621082513343"></p>
<p><a target="_blank" rel="noopener" href="https://help.aliyun.com/zh/ecs/support/query-and-case-analysis-linux-io-load?spm=a2c6h.13066369.question.5.6ef62f5000GwA0">如何查看 Linux 系统 I/O 负载情况_云服务器 ECS(ECS)-阿里云帮助中心 (aliyun.com)</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_30298379/article/details/135491162">云服务器一直提示达到云盘类型的 IOPS 上限_读写 io 延迟过长,或达到了该云盘类型的 iops 上限,导致实例云盘读写受限-CSDN 博客</a></p>
<p><a target="_blank" rel="noopener" href="https://www.linuxprobe.com/sdjbmrszwjss.html">swappiness 的基本默认设置为 60，加上生效这样便完成修改设置 | 《Linux 就该这么学》 (linuxprobe.com)</a></p>
<p><img src="http://blog.memory-life.xyz/image-20240621090629532.png" alt="image-20240621090629532"></p>
<p>我又重启了服务器实例，试了下上面的方法，看看是否有效。</p>
<p>半个小时过去了，好像问题还真的解决了：</p>
<p><img src="http://blog.memory-life.xyz/image-20240621092700202.png" alt="image-20240621092700202"></p>
<blockquote>
<p>2024 年 7 月 4 日</p>
</blockquote>
<p><img src="http://blog.memory-life.xyz/image-20240703234449094.png" alt="image-20240703234449094"></p>
<blockquote>
<p>2024 年 7 月 8 日</p>
</blockquote>
<p>还是老问题：</p>
<p><strong>服务器的 CPU 一直负载很高，监控告警也提示：</strong></p>
<p><strong>当前实例的云盘在 2024 年 7 月 4 日 09:43:00 出现读写 I0 延迟过长，或达到了该云盘类型的 I0PS 上限，导致实例云盘读写受限。</strong></p>
<p><strong>想要远程连接排查问题，Workbench 远程连接服务器又提示已禁用账号密码登录。</strong></p>
<p><strong>改用 VNC 远程连接，进去后没有任何反应，只能胡乱敲字母。</strong></p>
<p><strong>CPU 负载解决不了，部署在服务器上的博客也访问不到。</strong></p>
<p><img src="http://blog.memory-life.xyz/image-20240708082555734.png" alt="image-20240708082555734"></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_35995514/article/details/136542702">【Linux】iftop 命令详解-CSDN 博客</a></p>
<p><a target="_blank" rel="noopener" href="https://ecs.console.aliyun.com/activeDiagnosisReport/region/cn-beijing?IssueCategoryId=100,104&CurrentCategories=SystemLoadHigh,DiskHighLoad&DiagnosticReportId=dr-2ze9r976kxpb263w76c5">云服务器管理控制台 (aliyun.com)</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_42720845/article/details/138022301">Linux(CentOS)网络流量实时监控（iftop）安装教程——含 yum 命令安装失败方法_centos iftop-CSDN 博客</a></p>
<blockquote>
<p>2024 年 7 月 9 日</p>
</blockquote>
<p>AtomGit Pages 服务下的博客是 HTTPS 协议的，七牛云存储空间绑定的域名目前没有部署 SSL 证书，仅支持 HTTP 协议。</p>
<p>这图片还显示不了了。</p>
<p>又打回了云服务器部署博客的注意，今天早上 CPU 都爆满到 90% 了，肯定出问题了。</p>
<p><img src="http://blog.memory-life.xyz/image-20240709090451182.png"></p>
<p><img src="http://blog.memory-life.xyz/image-20240709090049445.png" alt="image-20240709090049445"></p>
<p>拒绝服务漏洞？这不就是问题的原因所在吗，摆明了在这我都没想过这个问题。。</p>
<p><a target="_blank" rel="noopener" href="https://avd.aliyun.com/detail/CVE-2022-27191?spm=0.2020520154.sas.11.2ce0Ar14Ar14Pj&lang=zh">阿里云漏洞库 (aliyun.com)</a></p>
<p><img src="http://blog.memory-life.xyz/image-20240709090222161.png" alt="image-20240709090222161"></p>
<p><img src="http://blog.memory-life.xyz/image-20240709090427796.png" alt="image-20240709090427796"></p>
<p><img src="http://blog.memory-life.xyz/image-20240709090316918.png" alt="image-20240709090316918"></p>
<p>按量付费，一次两块钱，我试试看。</p>
<p>晚上，睡觉前：</p>
<p><img src="http://blog.memory-life.xyz/image-20240710001714426.png" alt="image-20240710001714426"></p>
<h2 id="Nodejs-安装"><a href="#Nodejs-安装" class="headerlink" title="Nodejs 安装"></a>Nodejs 安装</h2><blockquote>
<p>2024 年 6 月 3 日</p>
</blockquote>
<p>linux 安装 nodejs yum</p>
<p>在 Linux 系统中，您可以使用 Yum 包管理器来安装 Node.js。以下是一个基本的步骤和示例代码，用于通过 Yum 安装 Node.js：</p>
<ol>
<li>首先，您需要确保您的系统中已经安装了 Node.js 的官方 Yum 仓库。如果尚未安装，您可以通过运行以下命令来添加 Node.js 的仓库：</li>
</ol>
<figure class="highlight armasm"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs armasm"><span class="hljs-symbol">curl</span> -<span class="hljs-built_in">sL</span> https:<span class="hljs-comment">//rpm.nodesource.com/setup_14.x | sudo bash -</span><br></code></pre></td></tr></table></figure>

<p><img src="http://blog.memory-life.xyz/image-20240604085311073.png" alt="image-20240604085311073"></p>
<p>这个命令会将 Node.js 14.x 的仓库添加到您的系统中。如果您想安装其他版本的 Node.js，只需将<code>setup_14.x</code>中的数字更改为所需的 Node.js 版本即可。</p>
<ol>
<li>接下来，您可以使用 Yum 安装 Node.js：</li>
</ol>
<figure class="highlight cmake"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs cmake">sudo yum <span class="hljs-keyword">install</span> -y nodejs<br></code></pre></td></tr></table></figure>

<p><img src="http://blog.memory-life.xyz/image-20240604085407699.png" alt="image-20240604085407699"></p>
<p>这个命令会从刚才添加的 Node.js 仓库中安装 Node.js。</p>
<ol>
<li>安装完成后，您可以检查 Node.js 的版本确保安装成功：</li>
</ol>
<figure class="highlight crmsh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs crmsh"><span class="hljs-keyword">node</span> <span class="hljs-title">--version</span><br></code></pre></td></tr></table></figure>

<p>请注意，上述命令中的 URL 和版本号可能会随着 Node.js 版本更新而变化，请参照 Node.js 官方文档或者 NodeSource 提供的最新安装脚本。</p>
<p><img src="http://blog.memory-life.xyz/image-20240604090040331.png" alt="image-20240604090040331"></p>
<p><img src="http://blog.memory-life.xyz/image-20240604105048890.png" alt="image-20240604105048890"></p>
<p><img src="http://blog.memory-life.xyz/image-20240604105149238.png" alt="image-20240604105149238"></p>
<h2 id="部署"><a href="#部署" class="headerlink" title="部署"></a>部署</h2><p>看过了上面的一条龙 Nginx 部署静态站点服务后，基本上搞定了所有 Nginx 问题</p>
<h2 id="Nginx-安装-1"><a href="#Nginx-安装-1" class="headerlink" title="Nginx 安装"></a>Nginx 安装</h2><blockquote>
<p>2024 年 6 月 9 日</p>
</blockquote>
<p>注意，这里还是上面提到的那篇博文内容，感觉还是把详细步骤记录下来比较好：</p>
<h3 id="安装-Nginx-步骤"><a href="#安装-Nginx-步骤" class="headerlink" title="安装 Nginx 步骤"></a><strong>安装 Nginx 步骤</strong></h3><p>有两种安装 Nginx 方法：</p>
<p>一种是快速安装，直接执行下面代码即可：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">yum install nginx<br></code></pre></td></tr></table></figure>

<p>另一种是设置 nginx.repo 源安装，我们推荐使用设置 nginx.repo 源安装，具体步骤如下所示：</p>
<h3 id="安装-yum-utils"><a href="#安装-yum-utils" class="headerlink" title="安装 yum-utils"></a><strong>安装 yum-utils</strong></h3><p>在安装之前，首先要安装 yum-utils，执行如下代码：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">yum install yum-utils<br></code></pre></td></tr></table></figure>

<h3 id="配置-nginx-repo-源"><a href="#配置-nginx-repo-源" class="headerlink" title="配置 nginx.repo 源"></a><strong>配置 nginx.repo 源</strong></h3><p>首先在/etc/yum.repos.d 目录下创建 nginx.repo 文件，执行如下代码：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-built_in">touch</span> /etc/yum.repos.d/nginx.repo<br></code></pre></td></tr></table></figure>

<p>在 nginx.repo 文件中写入以下代码：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><code class="hljs bash">vim /etc/yum.repos.d/nginx.repo  <span class="hljs-comment">#进入nginx.repo文件</span><br><span class="hljs-comment"># 写入以下代码：</span><br>[nginx-stable]<br>name=nginx stable repo<br>baseurl=http://nginx.org/packages/centos/<span class="hljs-variable">$releasever</span>/<span class="hljs-variable">$basearch</span>/<br>gpgcheck=1<br>enabled=1<br>gpgkey=https://nginx.org/keys/nginx_signing.key<br>module_hotfixes=<span class="hljs-literal">true</span><br><br>[nginx-mainline]<br>name=nginx mainline repo<br>baseurl=http://nginx.org/packages/mainline/centos/<span class="hljs-variable">$releasever</span>/<span class="hljs-variable">$basearch</span>/<br>gpgcheck=1<br>enabled=0<br>gpgkey=https://nginx.org/keys/nginx_signing.key<br>module_hotfixes=<span class="hljs-literal">true</span><br></code></pre></td></tr></table></figure>

<p>写入文件后，保存并退出，执行如下代码查看是否加载了 Nginx 安装源：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">yum repolist<br></code></pre></td></tr></table></figure>

<p><img src="https://pic1.zhimg.com/80/v2-06481da518e45426abb4da78d3f926d0_1440w.webp" alt="img"></p>
<h3 id="安装-nginx"><a href="#安装-nginx" class="headerlink" title="安装 nginx"></a><strong>安装 nginx</strong></h3><p>安装 nginx 执行如下代码即可安装：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">yum install nginx<br></code></pre></td></tr></table></figure>

<h3 id="系统启动-nginx-服务器"><a href="#系统启动-nginx-服务器" class="headerlink" title="系统启动 nginx 服务器"></a><strong>系统启动 nginx 服务器</strong></h3><p>在系统管理中，我们可以执行如下代码启动 nginx 服务器：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash">systemctl start nginx  <span class="hljs-comment">#启动nginx服务器</span><br>ps -aux | grep nginx  <span class="hljs-comment">#查看nginx进程</span><br></code></pre></td></tr></table></figure>

<p>如下图所示：</p>
<p><img src="https://pic2.zhimg.com/80/v2-358bcd2ab2eb80b2b6951522fb45d879_1440w.webp" alt="img"></p>
<p>这样就启动了 nginx 服务器，我们进入浏览器并输入公网 id 即可看到如下页面：</p>
<p><img src="https://pic4.zhimg.com/80/v2-20b977106f5a862933564a6756fed127_1440w.webp" alt="img"></p>
<p>假如没能成功显示该页面，则需要在云服务器开放 80 端口。</p>
<h3 id="nginx-conf-配置"><a href="#nginx-conf-配置" class="headerlink" title="nginx.conf 配置"></a><strong>nginx.conf 配置</strong></h3><p>为什么输入本机的 IP 地址就会显示上面的网页呢，带着疑问，我们来看看 Nginx 的配置文件，nginx 默认的配置文件 nginx.conf 的目录为：/etc/nginx/nginx.conf，也可以执行如下代码找出 nginx.conf 的位置：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">find -name nginx.conf<br></code></pre></td></tr></table></figure>

<p>如下图所示：</p>
<p><img src="https://pic4.zhimg.com/80/v2-affa2676eaaca61e117841043eb183fb_1440w.webp" alt="img"></p>
<p>找到 nginx.conf 配置文件路径后，进入 nginx.conf 配置文件：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><code class="hljs bash">vim /etc/nginx/nginx.conf<br>user  nginx;<br>worker_processes  auto;<br><br>error_log  /var/log/nginx/error.log notice;<br>pid        /var/run/nginx.pid;<br><br><br>events &#123;<br>    worker_connections  1024;<br>&#125;<br><br><br>http &#123;<br>    include       /etc/nginx/mime.types;<br>    default_type  application/octet-stream;<br><br>    log_format  main  <span class="hljs-string">&#x27;$remote_addr - $remote_user [$time_local] &quot;$request&quot; &#x27;</span><br>                      <span class="hljs-string">&#x27;$status $body_bytes_sent &quot;$http_referer&quot; &#x27;</span><br>                      <span class="hljs-string">&#x27;&quot;$http_user_agent&quot; &quot;$http_x_forwarded_for&quot;&#x27;</span>;<br><br>    access_log  /var/log/nginx/access.log  main;<br><br>    sendfile        on;<br>    <span class="hljs-comment">#tcp_nopush     on;</span><br><br>    keepalive_timeout  65;<br><br>    <span class="hljs-comment">#gzip  on;</span><br><br>    include /etc/nginx/conf.d/*.conf;<br>&#125;<br></code></pre></td></tr></table></figure>

<p>其内容如下所示：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><code class="hljs bash">user  nginx;     <span class="hljs-comment">#用户名</span><br>worker_processes  auto;    <span class="hljs-comment">#工作进程数为自动增加</span><br><br>error_log  /var/log/nginx/error.log notice;  <span class="hljs-comment">#错误日志文件</span><br>pid        /var/run/nginx.pid;    <span class="hljs-comment">#进程文件</span><br><br><br>events &#123;<br>    worker_connections  1024;  <span class="hljs-comment">#允许同时连接的连接数</span><br>&#125;<br><br><br>http &#123;<br>    include       /etc/nginx/mime.types;  <span class="hljs-comment">#http请求类型文件</span><br>    default_type  application/octet-stream;  <span class="hljs-comment">#默认为application的http请求</span><br><br>    log_format  main  <span class="hljs-string">&#x27;$remote_addr - $remote_user [$time_local] &quot;$request&quot; &#x27;</span><br>                      <span class="hljs-string">&#x27;$status $body_bytes_sent &quot;$http_referer&quot; &#x27;</span><br>                      <span class="hljs-string">&#x27;&quot;$http_user_agent&quot; &quot;$http_x_forwarded_for&quot;&#x27;</span>;  <span class="hljs-comment">#日志格式</span><br><br>    access_log  /var/log/nginx/access.log  main;    <span class="hljs-comment">#日志目录</span><br><br>    sendfile        on;<br>    <span class="hljs-comment">#tcp_nopush     on;</span><br><br>    keepalive_timeout  65;      <span class="hljs-comment">#连接超时时间</span><br><br>    <span class="hljs-comment">#gzip  on;        #压缩格式</span><br><br>    include /etc/nginx/conf.d/*.conf;  <span class="hljs-comment">#辅助配置文件</span><br>&#125;<br></code></pre></td></tr></table></figure>

<p>我们在 nginx.conf 配置文件中没有找到呈现刚才网页直接相关的代码，只有一个辅助配置文件，那么我们执行如下代码进入复制配置文件目录：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-built_in">cd</span> /etc/nginx/conf.d<br><span class="hljs-built_in">ls</span><br></code></pre></td></tr></table></figure>

<p>发现只有一个名为 default.conf 的配置文件，执行如下代码进入 default.conf 辅助配置文件：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">vim /etc/nginx/conf.d/*.conf<br></code></pre></td></tr></table></figure>

<p>其内容如下所示：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><code class="hljs bash">server &#123;<br>    listen       80;    <span class="hljs-comment">#服务器端口号</span><br>    server_name  localhost;   <span class="hljs-comment">#服务器名</span><br><br>    <span class="hljs-comment">#access_log  /var/log/nginx/host.access.log  main;</span><br><br>    location / &#123;         <span class="hljs-comment">#项目网址http:ip地址/</span><br>        root   /usr/share/nginx/html;   <span class="hljs-comment">#项目路径</span><br>        index  index.html index.htm;   <span class="hljs-comment">#http文件</span><br>    &#125;<br><br>    <span class="hljs-comment">#error_page  404              /404.html;</span><br><br>    <span class="hljs-comment"># redirect server error pages to the static page /50x.html</span><br>    <span class="hljs-comment">#</span><br>    error_page   500 502 503 504  /50x.html;  <span class="hljs-comment">#访问出错500,502,503,504时呈现50x.html网页</span><br>    location = /50x.html &#123;<br>        root   /usr/share/nginx/html;<br>    &#125;<br><br>    <span class="hljs-comment"># proxy the PHP scripts to Apache listening on 127.0.0.1:80</span><br>    <span class="hljs-comment">#</span><br>    <span class="hljs-comment">#location ~ \.php$ &#123;</span><br>    <span class="hljs-comment">#    proxy_pass   http://127.0.0.1;</span><br>    <span class="hljs-comment">#&#125;</span><br><br>    <span class="hljs-comment"># pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000</span><br>    <span class="hljs-comment">#</span><br>    <span class="hljs-comment">#location ~ \.php$ &#123;</span><br>    <span class="hljs-comment">#    root           html;</span><br>    <span class="hljs-comment">#    fastcgi_pass   127.0.0.1:9000;</span><br>    <span class="hljs-comment">#    fastcgi_index  index.php;</span><br>    <span class="hljs-comment">#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;</span><br>    <span class="hljs-comment">#    include        fastcgi_params;</span><br>    <span class="hljs-comment">#&#125;</span><br><br>    <span class="hljs-comment"># deny access to .htaccess files, if Apache&#x27;s document root</span><br>    <span class="hljs-comment"># concurs with nginx&#x27;s one</span><br>    <span class="hljs-comment">#</span><br>    <span class="hljs-comment">#location ~ /\.ht &#123;</span><br>    <span class="hljs-comment">#    deny  all;</span><br>    <span class="hljs-comment">#&#125;</span><br>&#125;<br></code></pre></td></tr></table></figure>

<p>在辅助配置文件中，我们找到了网页项目文件相关的代码，我们进入/usr/share/nginx/html 项目路径，执行如下代码：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">vim /usr/share/nginx/html/index.html<br></code></pre></td></tr></table></figure>

<p>打开 index.html，发现其内容正是我们刚才公网 id 访问浏览器显示的内容。</p>
<p>也就是说，只要我们修改 default.conf 配置文件中的项目路径改为我们项目的路径，即可把我们的项目放在服务器上面了，但是一般情况下，我们都不会去修改 nginx 原来的 default.conf 配置文件，一般会通过使用自定义的配置文件来启动 nginx 服务。</p>
<h3 id="关闭-nginx-服务器"><a href="#关闭-nginx-服务器" class="headerlink" title="关闭 nginx 服务器"></a><strong>关闭 nginx 服务器</strong></h3><p>当我们使用系统管理来启动 nginx 服务器时，需要系统管理来关闭 nginx 服务器，执行如下代码：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">systemctl stop nginx<br></code></pre></td></tr></table></figure>

<p>可以根据需求执行如下代码：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment">#通过系统管理nginx服务</span><br>systemctl <span class="hljs-built_in">enable</span> nginx   <span class="hljs-comment">#设置nginx为开机启动</span><br>systemctl <span class="hljs-built_in">disable</span> nginx  <span class="hljs-comment">#禁止开机启动</span><br>systemctl status nginx   <span class="hljs-comment">#查看nginx状态</span><br>systemctl start nginx   <span class="hljs-comment">#启动nginx服务</span><br>systemctl stop nginx <span class="hljs-comment">#关闭nginx服务</span><br></code></pre></td></tr></table></figure>

<h3 id="配置文件启动-nginx-服务"><a href="#配置文件启动-nginx-服务" class="headerlink" title="配置文件启动 nginx 服务"></a><strong>配置文件启动 nginx 服务</strong></h3><p>在使用系统管理启动 nginx 服务时，浏览器访问自身的 IP 地址呈现的是一个欢迎使用 nginx 服务的网页，要想浏览器访问自身的 IP 地址呈现的是其他网页时，需要修改其辅助配置文件 default.conf，但一般情况下，我们不会去修改 nginx 原来的 default.conf 配置文件，那么怎么启动 nginx 服务器让浏览器访问自身 IP 地址呈现其他网页呢？</p>
<p>这时我们可以自己编写一个 nginx 配置文件 mynginx.conf（配置文件名可以随意），执行以下代码来启动 nginx 服务：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">nginx -c 配置文件路径<br></code></pre></td></tr></table></figure>

<h3 id="配置文件编写"><a href="#配置文件编写" class="headerlink" title="配置文件编写"></a><strong>配置文件编写</strong></h3><p>那么问题来了，如何编写 nginx 配置文件呢？首先系统管理启动 nginx 服务涉及了两个配置文件——nginx.conf 和 default.conf，其中控制网页内容的呈现相关的是 default.conf 配置文件，而 nginx.conf 是一些日志、错误等一些文件配置，所以我们只需要把 nginx.conf 配置文件和 default.conf 配置文件的内容复制在自己编写的 mynginx.conf 配置文件即可，复制代码后，我们通过增删改查，最终得出以下代码：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><code class="hljs bash">user  root;       <span class="hljs-comment">#将nginx.conf的nginx改为root</span><br>worker_processes  auto;<br><br>error_log  /var/log/nginx/error.log notice;<br>pid        /var/run/nginx.pid;<br><br>events &#123;<br>    worker_connections  1024;<br>&#125;<br><br>http &#123;<br>    include       /etc/nginx/mime.types;<br>    default_type  application/octet-stream;<br><br>    log_format  main  <span class="hljs-string">&#x27;$remote_addr - $remote_user [$time_local] &quot;$request&quot; &#x27;</span><br>                      <span class="hljs-string">&#x27;$status $body_bytes_sent &quot;$http_referer&quot; &#x27;</span><br>                      <span class="hljs-string">&#x27;&quot;$http_user_agent&quot; &quot;$http_x_forwarded_for&quot;&#x27;</span>;<br><br>    access_log  /var/log/nginx/access.log  main;<br><br>    sendfile        on;<br>    <span class="hljs-comment">#tcp_nopush     on;</span><br><br>    keepalive_timeout  65;<br><br>    <span class="hljs-comment">#gzip  on;</span><br><br>    server &#123;        <span class="hljs-comment">#default.conf代码复制在nginx.conf配置文件的http里面，并将注释的代码删除</span><br>    listen       6789;<br>    server_name  localhost;<br><br>    location / &#123;<br>        root   /tmp/test/templates;    <span class="hljs-comment">#修改为你项目的路径</span><br>        index  Hello.html Hello.htm;    <span class="hljs-comment">#修改为你的首页网页</span><br>    &#125;<br>&#125;<br>&#125;<br></code></pre></td></tr></table></figure>

<p>修改的地方我们已经在代码中注释了，好了，通过简单的修改复制的代码，我们成功编写了自己的 nginx 配置文件 mynginx.conf，我们将配置文件放在 Flask 程序根目录中。</p>
<p>Flask 程序如下所示：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs bash">from flask import Flask, render_template<br>app = Flask(__name__)<br>app.config[<span class="hljs-string">&#x27;DEBUG&#x27;</span>]=True<br>app.config[<span class="hljs-string">&#x27;ENV&#x27;</span>]=<span class="hljs-string">&#x27;development&#x27;</span><br><br>@app.route(<span class="hljs-string">&#x27;/&#x27;</span>)<br>def hello_world():<br>    <span class="hljs-built_in">return</span> render_template(<span class="hljs-string">&#x27;Hello.html&#x27;</span>)<br><span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">&#x27;__main__&#x27;</span>:<br>    app.run()<br></code></pre></td></tr></table></figure>

<h3 id="启动-nginx-服务"><a href="#启动-nginx-服务" class="headerlink" title="启动 nginx 服务"></a><strong>启动 nginx 服务</strong></h3><p>好了，配置文件已经写好了，执行如下代码启动 nginx 服务：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash">nginx -c /root/demo/myflask/mynginx.conf   <span class="hljs-comment">#启动nginx服务</span><br>ps -aux | grep nginx       <span class="hljs-comment">#查看nginx进程</span><br></code></pre></td></tr></table></figure>

<p>这样我们就启动了自己编写的 nginx 配置文件，如下图所示：</p>
<p><img src="https://pic4.zhimg.com/80/v2-d9ad1e54609d48866fae8b1c7ff5d3cf_1440w.webp" alt="img"></p>
<p>浏览器访问<a href="https://link.zhihu.com/?target=http://ip">http://ip</a>:port，这里我们设置的端口号为 6789，如下图所示：</p>
<p><img src="https://pic2.zhimg.com/80/v2-90996ce157d005a672765faa64cc4291_1440w.webp" alt="img"></p>
<h3 id="关闭-nginx-服务"><a href="#关闭-nginx-服务" class="headerlink" title="关闭 nginx 服务"></a><strong>关闭 nginx 服务</strong></h3><p>通过配置文件启动 nginx 服务，需要执行如下代码关闭 nginx 服务：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs bash">nginx -s quit  <span class="hljs-comment">#正常关闭</span><br>nginx -s stop  <span class="hljs-comment">#快速关闭</span><br>nginx -s reload   <span class="hljs-comment">#重新加载配置</span><br></code></pre></td></tr></table></figure>

<p>好了，服务器——Nginx 安装及 Nginx 静态配置、部署就讲到这里了。</p>
<h2 id="Nginx-简介和安装"><a href="#Nginx-简介和安装" class="headerlink" title="Nginx 简介和安装"></a>Nginx 简介和安装</h2><ul>
<li><h5 id="了解-Nginx：功能、优势和应用场景"><a href="#了解-Nginx：功能、优势和应用场景" class="headerlink" title="了解 Nginx：功能、优势和应用场景"></a>了解 Nginx：功能、优势和应用场景</h5></li>
</ul>
<h3 id="简介"><a href="#简介" class="headerlink" title="简介"></a>简介</h3><ul>
<li><h5 id="这篇关于-Nginx-的介绍是我看过最详细的了：Nginx-学习-KuangStudy-文章"><a href="#这篇关于-Nginx-的介绍是我看过最详细的了：Nginx-学习-KuangStudy-文章" class="headerlink" title="这篇关于 Nginx 的介绍是我看过最详细的了：Nginx 学习-KuangStudy-文章"></a>这篇关于 Nginx 的介绍是我看过最详细的了：<a target="_blank" rel="noopener" href="https://www.kuangstudy.com/bbs/1483987971375263745">Nginx 学习-KuangStudy-文章</a></h5></li>
<li><h5 id="这里我就不详细展开说了，网上的资料对-Nginx-都有着详尽的介绍，我仅依照自己的理解，给出我对-Nginx-的认识："><a href="#这里我就不详细展开说了，网上的资料对-Nginx-都有着详尽的介绍，我仅依照自己的理解，给出我对-Nginx-的认识：" class="headerlink" title="这里我就不详细展开说了，网上的资料对 Nginx 都有着详尽的介绍，我仅依照自己的理解，给出我对 Nginx 的认识："></a>这里我就不详细展开说了，网上的资料对 Nginx 都有着详尽的介绍，我仅依照自己的理解，给出我对 Nginx 的认识：</h5></li>
<li><h5 id="Nginx-是一个高性能的-HTTP-和反向代理-web-服务器，它的特点是负载均衡、反向代理"><a href="#Nginx-是一个高性能的-HTTP-和反向代理-web-服务器，它的特点是负载均衡、反向代理" class="headerlink" title="Nginx 是一个高性能的 HTTP 和反向代理 web 服务器，它的特点是负载均衡、反向代理"></a>Nginx 是一个高性能的 HTTP 和反向代理 web 服务器，它的特点是负载均衡、反向代理</h5></li>
</ul>
<h3 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h3><h4 id="windows-安装"><a href="#windows-安装" class="headerlink" title="windows 安装"></a>windows 安装</h4><ul>
<li><h5 id="Nginx-官网下载：nginx-download"><a href="#Nginx-官网下载：nginx-download" class="headerlink" title="Nginx 官网下载：nginx: download"></a>Nginx 官网下载：<a target="_blank" rel="noopener" href="http://nginx.org/en/download.html">nginx: download</a></h5></li>
<li><h5 id="只需在官网下载安装包，在本地解压即可"><a href="#只需在官网下载安装包，在本地解压即可" class="headerlink" title="只需在官网下载安装包，在本地解压即可"></a>只需在官网下载安装包，在本地解压即可</h5></li>
</ul>
<h4 id="本地-Linux-原始安装"><a href="#本地-Linux-原始安装" class="headerlink" title="本地 Linux 原始安装"></a>本地 Linux 原始安装</h4><ul>
<li><h5 id="手动安装并手动配置是很繁琐的，不过操作一遍确实很能巩固-Linux-命令，这里给出详细的安装教程："><a href="#手动安装并手动配置是很繁琐的，不过操作一遍确实很能巩固-Linux-命令，这里给出详细的安装教程：" class="headerlink" title="手动安装并手动配置是很繁琐的，不过操作一遍确实很能巩固 Linux 命令，这里给出详细的安装教程："></a>手动安装并手动配置是很繁琐的，不过操作一遍确实很能巩固 Linux 命令，这里给出详细的安装教程：</h5></li>
<li><h5 id="Nginx-官网下载：nginx-download-1"><a href="#Nginx-官网下载：nginx-download-1" class="headerlink" title="Nginx 官网下载：nginx: download"></a>Nginx 官网下载：<a target="_blank" rel="noopener" href="http://nginx.org/en/download.html">nginx: download</a></h5></li>
<li><h5 id="教程一：Nginx-安装下载-KuangStudy-文章"><a href="#教程一：Nginx-安装下载-KuangStudy-文章" class="headerlink" title="教程一：Nginx 安装下载-KuangStudy-文章"></a>教程一：<a target="_blank" rel="noopener" href="https://www.kuangstudy.com/bbs/1511610238649233410">Nginx 安装下载-KuangStudy-文章</a></h5></li>
<li><h5 id="教程二：-67-条消息-Nginx-安装及其常用命令（实操版）nginx-安装命令叫我-默语的博客-CSDN-博客"><a href="#教程二：-67-条消息-Nginx-安装及其常用命令（实操版）nginx-安装命令叫我-默语的博客-CSDN-博客" class="headerlink" title="教程二：(67 条消息) Nginx 安装及其常用命令（实操版）nginx 安装命令叫我 默语的博客-CSDN 博客"></a>教程二：<a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_42055933/article/details/130734077">(67 条消息) Nginx 安装及其常用命令（实操版）<em>nginx 安装命令</em>叫我 默语的博客-CSDN 博客</a></h5></li>
<li><h5 id="教程三：-67-条消息-yum-安装-nginx-yum-安装-nginx-q495673918-的博客-CSDN-博客"><a href="#教程三：-67-条消息-yum-安装-nginx-yum-安装-nginx-q495673918-的博客-CSDN-博客" class="headerlink" title="教程三：(67 条消息) yum 安装 nginx_yum 安装 nginx_q495673918 的博客-CSDN 博客"></a>教程三：<a target="_blank" rel="noopener" href="https://blog.csdn.net/q495673918/article/details/124477891">(67 条消息) yum 安装 nginx_yum 安装 nginx_q495673918 的博客-CSDN 博客</a></h5></li>
<li><h5 id="将来有空的话，我会补充这里的手动安装实操流程（宝塔一键安装真的太便捷了）"><a href="#将来有空的话，我会补充这里的手动安装实操流程（宝塔一键安装真的太便捷了）" class="headerlink" title="将来有空的话，我会补充这里的手动安装实操流程（宝塔一键安装真的太便捷了）"></a>将来有空的话，我会补充这里的手动安装实操流程（宝塔一键安装真的太便捷了）</h5></li>
</ul>
<h4 id="宝塔-Linux-一键安装"><a href="#宝塔-Linux-一键安装" class="headerlink" title="宝塔 Linux 一键安装"></a>宝塔 Linux 一键安装</h4><ul>
<li><h5 id="不论是云服务器还是本地服务器，宝塔-Linux-都是一键安装的，省去了大部分繁琐的配置"><a href="#不论是云服务器还是本地服务器，宝塔-Linux-都是一键安装的，省去了大部分繁琐的配置" class="headerlink" title="不论是云服务器还是本地服务器，宝塔 Linux 都是一键安装的，省去了大部分繁琐的配置"></a>不论是云服务器还是本地服务器，宝塔 Linux 都是一键安装的，省去了大部分繁琐的配置</h5></li>
<li><h5 id="你可以在登录宝塔面板之后，在软件商店里下载安装："><a href="#你可以在登录宝塔面板之后，在软件商店里下载安装：" class="headerlink" title="你可以在登录宝塔面板之后，在软件商店里下载安装："></a>你可以在登录宝塔面板之后，在软件商店里下载安装：</h5></li>
</ul>
<img src="http://blog.memory-life.xyz/image-20230622143528026.png" alt="image-20230622143528026" style="zoom:150%;" />

<ul>
<li><h5 id="也可以在终端里，像本地-Linux-服务器一样，使用命令安装配置-Nginx"><a href="#也可以在终端里，像本地-Linux-服务器一样，使用命令安装配置-Nginx" class="headerlink" title="也可以在终端里，像本地 Linux 服务器一样，使用命令安装配置 Nginx"></a>也可以在终端里，像本地 Linux 服务器一样，使用命令安装配置 Nginx</h5></li>
</ul>
<h2 id="服务启停"><a href="#服务启停" class="headerlink" title="服务启停"></a>服务启停</h2><ul>
<li><h5 id="学会安装、启动和停止-Nginx-服务"><a href="#学会安装、启动和停止-Nginx-服务" class="headerlink" title="学会安装、启动和停止 Nginx 服务"></a>学会安装、启动和停止 Nginx 服务</h5></li>
<li><h5 id="这里补充下-Nginx-常用命令："><a href="#这里补充下-Nginx-常用命令：" class="headerlink" title="这里补充下 Nginx 常用命令："></a>这里补充下 Nginx 常用命令：</h5></li>
</ul>
<figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs nginx"><span class="hljs-attribute">nginx</span> 					<span class="hljs-comment"># 启动Nginx</span><br></code></pre></td></tr></table></figure>

<figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs nginx"><span class="hljs-attribute">nginx</span> -c filename  		<span class="hljs-comment"># 指定配置⽂件</span><br></code></pre></td></tr></table></figure>

<figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs nginx"><span class="hljs-attribute">nginx</span> -V 				<span class="hljs-comment"># 查看Nginx的版本和编译参数等信息</span><br></code></pre></td></tr></table></figure>

<figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs nginx"><span class="hljs-attribute">nginx</span> -t 				<span class="hljs-comment"># 检查配置⽂件是否正确，也可⽤来定位配置⽂件的位置</span><br></code></pre></td></tr></table></figure>

<figure class="highlight jboss-cli"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs jboss-cli">nginx -s <span class="hljs-keyword">quit</span> 			<span class="hljs-comment"># 优雅停⽌Nginx</span><br></code></pre></td></tr></table></figure>

<figure class="highlight crmsh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs crmsh">nginx -s <span class="hljs-literal">stop</span> 			<span class="hljs-comment"># 快速停⽌Nginx</span><br></code></pre></td></tr></table></figure>

<figure class="highlight jboss-cli"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs jboss-cli">nginx -s <span class="hljs-keyword">reload</span> 		<span class="hljs-comment"># 重新加载配置⽂件</span><br></code></pre></td></tr></table></figure>

<figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs nginx"><span class="hljs-attribute">nginx</span> -s reopen 		<span class="hljs-comment"># 重新打开⽇志⽂件</span><br></code></pre></td></tr></table></figure>

<h2 id="配置文件"><a href="#配置文件" class="headerlink" title="配置文件"></a>配置文件</h2><blockquote>
<p>🔥 推荐阅读：</p>
</blockquote>
<ul>
<li><h5 id="深入理解-Nginx-配置文件：语法、块和常用指令"><a href="#深入理解-Nginx-配置文件：语法、块和常用指令" class="headerlink" title="深入理解 Nginx 配置文件：语法、块和常用指令"></a>深入理解 Nginx 配置文件：语法、块和常用指令</h5></li>
<li><h5 id="介绍下-Nginx-目录结构和配置文件的内容："><a href="#介绍下-Nginx-目录结构和配置文件的内容：" class="headerlink" title="介绍下 Nginx 目录结构和配置文件的内容："></a>介绍下 Nginx 目录结构和配置文件的内容：</h5></li>
<li><h5 id="67-条消息-Nginx-目录结构与配置文件详解nginx-目录不会调制解调的猫的博客-CSDN-博客"><a href="#67-条消息-Nginx-目录结构与配置文件详解nginx-目录不会调制解调的猫的博客-CSDN-博客" class="headerlink" title="(67 条消息) Nginx - 目录结构与配置文件详解nginx 目录不会调制解调的猫的博客-CSDN 博客"></a><a target="_blank" rel="noopener" href="https://blog.csdn.net/Trollz/article/details/126525238">(67 条消息) Nginx - 目录结构与配置文件详解<em>nginx 目录</em>不会调制解调的猫的博客-CSDN 博客</a></h5></li>
<li><h5 id="Nginx-的配置文件详解-KuangStudy-文章-1"><a href="#Nginx-的配置文件详解-KuangStudy-文章-1" class="headerlink" title="Nginx 的配置文件详解-KuangStudy-文章"></a><a target="_blank" rel="noopener" href="https://www.kuangstudy.com/bbs/1619965646882693121">Nginx 的配置文件详解-KuangStudy-文章</a></h5></li>
</ul>
<h2 id="反向代理和负载均衡"><a href="#反向代理和负载均衡" class="headerlink" title="反向代理和负载均衡"></a>反向代理和负载均衡</h2><ul>
<li><h5 id="Nginx-反向代理和负载均衡：有效分发流量"><a href="#Nginx-反向代理和负载均衡：有效分发流量" class="headerlink" title="Nginx 反向代理和负载均衡：有效分发流量"></a>Nginx 反向代理和负载均衡：有效分发流量</h5></li>
<li><h5 id="我们在本地的-4000、5173、8080-三个端口开启静态站点服务："><a href="#我们在本地的-4000、5173、8080-三个端口开启静态站点服务：" class="headerlink" title="我们在本地的 4000、5173、8080 三个端口开启静态站点服务："></a>我们在本地的 4000、5173、8080 三个端口开启静态站点服务：</h5></li>
</ul>
<p><img src="C:\Users\Lenovo\AppData\Roaming\Typora\typora-user-images\image-20230708095447602.png" alt="image-20230708095447602"></p>
<p><img src="http://blog.memory-life.xyz/image-20230708095520028.png" alt="image-20230708095520028"></p>
<p><img src="http://blog.memory-life.xyz/image-20230708095552638.png" alt="image-20230708095552638"></p>
<ul>
<li><h5 id="在-nginx-conf-文件下，分别开放-8887、8888、8889-端口，反向代理三个静态站点服务"><a href="#在-nginx-conf-文件下，分别开放-8887、8888、8889-端口，反向代理三个静态站点服务" class="headerlink" title="在 nginx.conf 文件下，分别开放 8887、8888、8889 端口，反向代理三个静态站点服务"></a>在 nginx.conf 文件下，分别开放 8887、8888、8889 端口，反向代理三个静态站点服务</h5></li>
<li><h5 id="详细配置如下："><a href="#详细配置如下：" class="headerlink" title="详细配置如下："></a>详细配置如下：</h5></li>
</ul>
<figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br></pre></td><td class="code"><pre><code class="hljs nginx"><span class="hljs-section">http</span> &#123;<br>    <span class="hljs-attribute">include</span>       mime.types;<br>    <span class="hljs-attribute">default_type</span>  application/json;<br><br>    <span class="hljs-attribute">sendfile</span>        <span class="hljs-literal">on</span>;<br><br>    <span class="hljs-attribute">keepalive_timeout</span>  <span class="hljs-number">65</span>;<br><br>    <span class="hljs-section">upstream</span> memory-blog &#123;<br>      <span class="hljs-attribute">server</span> localhost:<span class="hljs-number">4000</span>;<br>    &#125;<br><br>    <span class="hljs-section">upstream</span> memory-docs1 &#123;<br>      <span class="hljs-attribute">server</span> localhost:<span class="hljs-number">5173</span>;<br>    &#125;<br><br>    <span class="hljs-section">upstream</span> memory-docs2 &#123;<br>      <span class="hljs-attribute">server</span> localhost:<span class="hljs-number">8080</span>;<br>    &#125;<br><br>    <span class="hljs-section">server</span> &#123;<br>        <span class="hljs-attribute">listen</span>       <span class="hljs-number">8887</span>;<br>        <span class="hljs-attribute">server_name</span>  localhost;<br><br>        <span class="hljs-section">location</span> / &#123;<br>            <span class="hljs-attribute">proxy_pass</span>  http://memory-blog;<br>        &#125;<br><br>        <span class="hljs-attribute">error_page</span>   <span class="hljs-number">500</span> <span class="hljs-number">502</span> <span class="hljs-number">503</span> <span class="hljs-number">504</span>  /50x.html;<br>        <span class="hljs-section">location</span> = /50x.html &#123;<br>            <span class="hljs-attribute">root</span>   html;<br>        &#125;<br>    &#125;<br><br>    <span class="hljs-section">server</span> &#123;<br>        <span class="hljs-attribute">listen</span>       <span class="hljs-number">8888</span>;<br>        <span class="hljs-attribute">server_name</span>  localhost;<br><br>        <span class="hljs-section">location</span> / &#123;<br>            <span class="hljs-attribute">proxy_pass</span>  http://memory-docs1;<br>        &#125;<br><br>        <span class="hljs-attribute">error_page</span>   <span class="hljs-number">500</span> <span class="hljs-number">502</span> <span class="hljs-number">503</span> <span class="hljs-number">504</span>  /50x.html;<br>        <span class="hljs-section">location</span> = /50x.html &#123;<br>            <span class="hljs-attribute">root</span>   html;<br>        &#125;<br>    &#125;<br><br><br>    <span class="hljs-section">server</span> &#123;<br>        <span class="hljs-attribute">listen</span>       <span class="hljs-number">8889</span>;<br>        <span class="hljs-attribute">server_name</span>  localhost;<br><br>        <span class="hljs-section">location</span> / &#123;<br>            <span class="hljs-attribute">proxy_pass</span>  http://memory-docs2;<br>        &#125;<br><br>        <span class="hljs-attribute">error_page</span>   <span class="hljs-number">500</span> <span class="hljs-number">502</span> <span class="hljs-number">503</span> <span class="hljs-number">504</span>  /50x.html;<br>        <span class="hljs-section">location</span> = /50x.html &#123;<br>            <span class="hljs-attribute">root</span>   html;<br>        &#125;<br>    &#125;<br>&#125;<br></code></pre></td></tr></table></figure>

<ul>
<li><h5 id="有关配置的详细讲解，在配置文件-👆-一栏中了解"><a href="#有关配置的详细讲解，在配置文件-👆-一栏中了解" class="headerlink" title="有关配置的详细讲解，在配置文件 👆 一栏中了解"></a>有关配置的详细讲解，在配置文件 👆 一栏中了解</h5></li>
<li><h5 id="修改完配置，我们重新加载配置文件，并启动-Nginx-服务"><a href="#修改完配置，我们重新加载配置文件，并启动-Nginx-服务" class="headerlink" title="修改完配置，我们重新加载配置文件，并启动 Nginx 服务"></a>修改完配置，我们重新加载配置文件，并启动 Nginx 服务</h5></li>
</ul>
<figure class="highlight ebnf"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs ebnf"><span class="hljs-attribute">nginx -s reload</span><br></code></pre></td></tr></table></figure>

<figure class="highlight ebnf"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs ebnf"><span class="hljs-attribute">nginx</span><br></code></pre></td></tr></table></figure>

<ul>
<li><h5 id="分别访问本地-8887、8888、8889-端口："><a href="#分别访问本地-8887、8888、8889-端口：" class="headerlink" title="分别访问本地 8887、8888、8889 端口："></a>分别访问本地 8887、8888、8889 端口：</h5></li>
</ul>
<p><img src="http://blog.memory-life.xyz/image-20230708100936095.png" alt="image-20230708100936095"></p>
<p><img src="http://blog.memory-life.xyz/image-20230708100544510.png" alt="image-20230708100544510"></p>
<p><img src="http://blog.memory-life.xyz/image-20230708100612584.png" alt="image-20230708100612584"></p>
<ul>
<li><h5 id="可以看到，我们开启了-Nginx-服务，只需访问-Nginx-给我们开放的端口，就能够访问到对应服务器，获取页面数据"><a href="#可以看到，我们开启了-Nginx-服务，只需访问-Nginx-给我们开放的端口，就能够访问到对应服务器，获取页面数据" class="headerlink" title="可以看到，我们开启了 Nginx 服务，只需访问 Nginx 给我们开放的端口，就能够访问到对应服务器，获取页面数据"></a>可以看到，我们开启了 Nginx 服务，只需访问 Nginx 给我们开放的端口，就能够访问到对应服务器，获取页面数据</h5></li>
<li><h5 id="这是因为-Nginx-将我们的请求转发给了服务器，而用户是无感知的，这就是-Nginx-反向代理"><a href="#这是因为-Nginx-将我们的请求转发给了服务器，而用户是无感知的，这就是-Nginx-反向代理" class="headerlink" title="这是因为 Nginx 将我们的请求转发给了服务器，而用户是无感知的，这就是 Nginx 反向代理"></a>这是因为 Nginx 将我们的请求转发给了服务器，而用户是无感知的，这就是 Nginx 反向代理</h5></li>
</ul>
<h2 id="静态网站部署"><a href="#静态网站部署" class="headerlink" title="静态网站部署"></a>静态网站部署</h2><h2 id="HTTPS-配置"><a href="#HTTPS-配置" class="headerlink" title="HTTPS 配置"></a>HTTPS 配置</h2><ul>
<li><h5 id="使用-Nginx-配置-HTTPS：安全加密通信"><a href="#使用-Nginx-配置-HTTPS：安全加密通信" class="headerlink" title="使用 Nginx 配置 HTTPS：安全加密通信"></a>使用 Nginx 配置 HTTPS：安全加密通信</h5></li>
</ul>
<h2 id="虚拟主机"><a href="#虚拟主机" class="headerlink" title="虚拟主机"></a>虚拟主机</h2><ul>
<li><h5 id="Nginx-虚拟主机配置：多个网站共享一台服务器"><a href="#Nginx-虚拟主机配置：多个网站共享一台服务器" class="headerlink" title="Nginx 虚拟主机配置：多个网站共享一台服务器"></a>Nginx 虚拟主机配置：多个网站共享一台服务器</h5></li>
</ul>
<h2 id="踩坑经历"><a href="#踩坑经历" class="headerlink" title="踩坑经历"></a>踩坑经历</h2><h3 id="访问-Nginx403-错误"><a href="#访问-Nginx403-错误" class="headerlink" title="访问 Nginx403 错误"></a>访问 Nginx403 错误</h3><ul>
<li><h5 id="运维排查篇-访问-nginx-出现-403-错误-知乎-zhihu-com"><a href="#运维排查篇-访问-nginx-出现-403-错误-知乎-zhihu-com" class="headerlink" title="运维排查篇 | 访问 nginx 出现 403 错误 - 知乎 (zhihu.com)"></a><a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/381967653">运维排查篇 | 访问 nginx 出现 403 错误 - 知乎 (zhihu.com)</a></h5></li>
<li><h5 id="详解-Nginx-出现-403Forbidden-的解决办法-第一-PHP-社区-php1-cn"><a href="#详解-Nginx-出现-403Forbidden-的解决办法-第一-PHP-社区-php1-cn" class="headerlink" title="详解 Nginx 出现 403Forbidden 的解决办法 - 第一 PHP 社区 (php1.cn)"></a><a target="_blank" rel="noopener" href="https://www.php1.cn/detail/XiangJie_Nginx_C_5d37dae4.html">详解 Nginx 出现 403Forbidden 的解决办法 - 第一 PHP 社区 (php1.cn)</a></h5></li>
<li><h5 id="四种解决-Nginx-出现-403-forbidden-报错的方法-baidu-com"><a href="#四种解决-Nginx-出现-403-forbidden-报错的方法-baidu-com" class="headerlink" title="四种解决 Nginx 出现 403 forbidden 报错的方法 (baidu.com)"></a><a target="_blank" rel="noopener" href="https://baijiahao.baidu.com/s?id=1614533633678689239&wfr=spider&for=pc">四种解决 Nginx 出现 403 forbidden 报错的方法 (baidu.com)</a></h5></li>
<li><h5 id="先是看了很多解决办法（以上），虽然没有解决，但丰富了我对-Nginx-配置的理解"><a href="#先是看了很多解决办法（以上），虽然没有解决，但丰富了我对-Nginx-配置的理解" class="headerlink" title="先是看了很多解决办法（以上），虽然没有解决，但丰富了我对 Nginx 配置的理解"></a>先是看了很多解决办法（以上），虽然没有解决，但丰富了我对 Nginx 配置的理解</h5></li>
<li><h5 id="然后我想到看错误日志，但查看配置发现默认没开启，那就开启错误日志："><a href="#然后我想到看错误日志，但查看配置发现默认没开启，那就开启错误日志：" class="headerlink" title="然后我想到看错误日志，但查看配置发现默认没开启，那就开启错误日志："></a>然后我想到看错误日志，但查看配置发现默认没开启，那就开启错误日志：</h5></li>
<li><h5 id="错误日志路径："><a href="#错误日志路径：" class="headerlink" title="错误日志路径："></a>错误日志路径：</h5></li>
</ul>
<img src="http://blog.memory-life.xyz/image-20230622154436897.png" style="zoom:67%;" />

<ul>
<li><h5 id="开启错误日志："><a href="#开启错误日志：" class="headerlink" title="开启错误日志："></a>开启错误日志：</h5></li>
</ul>
<img src="http://blog.memory-life.xyz/image-20230622154707468.png" alt="image-20230622154707468" style="zoom: 80%;" />

<ul>
<li><h5 id="查看错误日志，发现问题所在："><a href="#查看错误日志，发现问题所在：" class="headerlink" title="查看错误日志，发现问题所在："></a>查看错误日志，发现问题所在：</h5></li>
</ul>
<img src="http://blog.memory-life.xyz/image-20230622154920109.png" alt="image-20230622154920109" style="zoom:150%;" />

<ul>
<li><h5 id="接着看这个解决思路：-67-条消息-报错：directory-index-of-“xxx“-is-forbidden-directory-index-of-is-forbidden-AI-人工智能与大数据的博客-CSDN-博客"><a href="#接着看这个解决思路：-67-条消息-报错：directory-index-of-“xxx“-is-forbidden-directory-index-of-is-forbidden-AI-人工智能与大数据的博客-CSDN-博客" class="headerlink" title="接着看这个解决思路：(67 条消息) 报错：directory index of “xxx“ is forbidden_directory index of is forbidden_AI 人工智能与大数据的博客-CSDN 博客"></a>接着看这个解决思路：<a target="_blank" rel="noopener" href="https://blog.csdn.net/guanxs/article/details/107901101">(67 条消息) 报错：directory index of “xxx“ is forbidden_directory index of is forbidden_AI 人工智能与大数据的博客-CSDN 博客</a></h5></li>
<li><h5 id="添加这行配置："><a href="#添加这行配置：" class="headerlink" title="添加这行配置："></a>添加这行配置：</h5></li>
</ul>
<img src="http://blog.memory-life.xyz/image-20230622155144376.png" alt="image-20230622155144376" style="zoom: 80%;" />

<ul>
<li><h5 id="然后访问-Nginx（记得-nginx-s-reload），访问成功，大功告成"><a href="#然后访问-Nginx（记得-nginx-s-reload），访问成功，大功告成" class="headerlink" title="然后访问 Nginx（记得 nginx -s reload），访问成功，大功告成"></a>然后访问 Nginx（记得 nginx -s reload），访问成功，大功告成</h5></li>
<li><h5 id="这就是访问-Nginx-发生-403-错误的具体解决办法了，很有收获"><a href="#这就是访问-Nginx-发生-403-错误的具体解决办法了，很有收获" class="headerlink" title="这就是访问 Nginx 发生 403 错误的具体解决办法了，很有收获"></a>这就是访问 Nginx 发生 403 错误的具体解决办法了，很有收获</h5></li>
</ul>
<h1 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h1>
                
              </div>
            
            <hr/>
            <div>
              <!-- 文章页面 - 底部标签 -->
<div class="post-metas my-3">
  
  <div class="post-meta mr-3 d-flex align-items-center">
    <i class="iconfont icon-category"></i>
    <!-- 归档页 - 文章列表 -->


<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/blog/categories/%E4%BB%A3%E7%A0%81%E9%94%8B%E8%8A%92/" class="category-chain-item">代码锋芒</a>
  
  
    <span>></span>
    
  <a href="/blog/categories/%E4%BB%A3%E7%A0%81%E9%94%8B%E8%8A%92/%E9%83%A8%E7%BD%B2%E4%B9%8B%E9%81%93/" class="category-chain-item">部署之道</a>
  
  

  

      </span>
    
  
</span>

  </div>
   
  <div class="post-meta">
    <i class="iconfont icon-tags"></i>
    
    <a href="/blog/tags/%E7%BB%8F%E9%AA%8C/">#经验</a>
    
    <a href="/blog/tags/Nginx/">#Nginx</a>
    
    <a href="/blog/tags/Linux/">#Linux</a>
    
    <a href="/blog/tags/Node-js/">#Node.js</a>
    
  </div>
  
</div>


              <!-- 文章页面 - 底部标签下方 -->

  
  <div class="license-box my-3">
    <div class="license-title">
      <div>Nginx 入门指南：理解、配置和优化</div>
      <div>https://test.atomgit.net/blog/2023/06/22/Nginx 入门指南：理解、配置和优化/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>Memory</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2023年6月22日</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>更新于</div>
          <div>2024年7月9日</div>
        </div>
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/blog/2023/06/22/AI%20%E5%AE%9E%E8%B7%B5%E4%B8%AD%E7%9A%84%E6%B4%9E%E8%A7%81%EF%BC%9A%E6%88%91%E7%9A%84%20AI%20%E4%B9%8B%E6%97%85/" title="AI实践中的洞见：我的AI之旅">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">AI实践中的洞见：我的AI之旅</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/blog/2023/06/20/Typora%E6%93%8D%E4%BD%9C%E6%8A%80%E5%B7%A7/" title="美轮美奂的文档艺术：Typora的使用技巧和实践">
                        <span class="hidden-mobile">美轮美奂的文档艺术：Typora的使用技巧和实践</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            <!-- 文章页 - 评论上方 -->

  
  
    <article id="comments">
      
  <div id="valine"></div>
  <script type="text/javascript">
    Fluid.utils.loadComments('#valine', function() {
      Fluid.utils.createScript('https://cdn.jsdelivr.net/gh/HCLonely/Valine@latest/dist/Valine.min.js', function() {
        var options = Object.assign(
          {"appId":"T1hUHH9Ks1ggG9DBE3HgUPpV-gzGzoHsz","appKey":"XFkgzzvzNo3J3uNCbBiSOFKc","path":"window.location.pathname","placeholder":"填取QQ号和邮箱后评论，支持读取头像及消息提醒，留下点什么叭... ᶘ ᵒᴥᵒᶅ","avatar":"Gravatar","meta":["nick","mail","link"],"requiredFields":[],"pageSize":10,"lang":"zh-CN","highlight":true,"recordIP":false,"serverURLs":"https://t1huhh9k.lc-cn-n1-shared.com","emojiCDN":null,"emojiMaps":null,"enableQQ":true,"master":"8c9b6d6637904da62d74d019cc6982de","friends":"0188229a9cfc284176ea9135cb9514cc","visitor":true},
          {
            el: "#valine",
            path: window.location.pathname,
            app_id: "",
            app_key: "",
            placeholder: "填取QQ号和邮箱后评论，支持读取头像及消息提醒，留下点什么叭... ᶘ ᵒᴥᵒᶅ",
            avatar: "Gravatar",
            meta: ["nick","mail","link"],
            pageSize: "10",
            lang: "zh-CN",
            highlight: true,
            recordIP: false,
            serverURLs: "https://t1huhh9k.lc-cn-n1-shared.com",

            // 设置Bilibili表情包地址
            emojiCDN: '//i0.hdslb.com/bfs/emote/', 
            // 表情title和图片映射
            emojiMaps: {
                "tv_白眼": "48f75163437445665a9be80bb316e4cb252c5415.gif@48w_48h.webp",
                "tv_doge": "302d6c88c63ed162c81a49cafe7ed2709e6fb955.gif@48w_48h.webp",
                "tv_坏笑": "5d2572efd09aab5dde9e2a198bb3f9ac1e2a982e.gif@48w_48h.webp",
                "tv_难过": "9c6b41008a67755410f712334c64313df5f91b3f.gif@48w_48h.webp",
                "tv_生气": "1902a5a2df5b5c931d88c12f0feb264b1e109d0d.gif@48w_48h.webp",
                "tv_委屈": "af5a5853edb43a8178a8cb5df707fa5e88143699.gif@48w_48h.webp",
                "tv_斜眼笑": "c66568b471192ca1f62f6ed4384dc1b283ab7508.gif@48w_48h.webp",
                "tv_呆": "d3fa91e4db9215eb1e20ab9da44f1214aa4bda7b.gif@48w_48h.webp",
                "tv_发怒": "3959eb81b952e4fa8d269d98f9e3639172d84073.gif@48w_48h.webp",
                "tv_呕吐": "db58e9442aae26694af18cc1683607cca3a16763.gif@48w_48h.webp",
                "tv_思考": "b63f9146bfd985af014f8d6d4bdb498805be48f9.gif@48w_48h.webp",
                "tv_微笑": "b98656855d782f61cb8edc7f7fca6563ecafff7e.gif@48w_48h.webp",
                "tv_疑问": "fce1b1a0f3b0e39a2dc16a18508dba7b91e929f4.gif@48w_48h.webp",
                "tv_大哭": "cba61f05f3039b02a7ffc0dfcd9d7995df9fdd74.gif@48w_48h.webp",
                "tv_鼓掌": "be106e6b265883a9f28fbe10f7b765701e2618d4.gif@48w_48h.webp",
                "tv_抠鼻": "696d9f93e722144dc2a78aeffc569418fdf3d565.gif@48w_48h.webp",
                "tv_亲亲": "3534ea44ab74bd20352b88c245a06c4b4c46d271.gif@48w_48h.webp",
                "tv_调皮": "fcd967395fd14e4dd5829fa7e8a967ce23205e52.gif@48w_48h.webp",
                "tv_笑哭": "1c2fd1e8c9dde12812f86e5d4cbddd8993d98082.gif@48w_48h.webp",
                "tv_晕": "030040ec5c9ddc9e3d067658c4139e7314ab42f8.gif@48w_48h.webp",
                "tv_点赞": "30ecff401245fb56bcc1cf588d1809ac1ab1607c.gif@48w_48h.webp",
                "tv_害羞": "411a3e459e8580f5bfd9f639a408247c4b509935.gif@48w_48h.webp",
                "tv_睡着": "3c8b5e293261287a6203597e29b3de07df4d18c6.gif@48w_48h.webp",
                "tv_色": "a0c6d99ab0ab63b8648f5283ff72cec04b604828.gif@48w_48h.webp",
                "tv_吐血": "e17e4539e169d14a3389ff147afea760cebe5de5.gif@48w_48h.webp",
                "tv_无奈": "eb4cb5f07cfd177c7e6a7914316717e56d9cc1d0.gif@48w_48h.webp",
                "tv_再见": "344f61609ecce2008520dc8a977b6169215748a9.gif@48w_48h.webp",
                "tv_流汗": "390bccec65eaff536bd5bb2a0c5b8b0bdea47334.gif@48w_48h.webp",
                "tv_偷笑": "7f11e6f7f63e79112b833bd41fa13a83d7cd8474.gif@48w_48h.webp",
                "tv_抓狂":"a476b93ecd8e94ac3257323fd822f91cef212de2.gif@48w_48h.webp",
                "tv_黑人问号":"b609adf664be33224a9923262031165ae3e34cd2.gif@48w_48h.webp",
                "tv_困":"91c2bf34ecf842d7016c01d841db3d4074bd281f.gif@48w_48h.webp",
                "tv_打脸":"b0fad4856e59c1240e448437da3287bb5ce547e5.gif@48w_48h.webp",
                "tv_闭嘴":"a3fc5388b09e945be3f18fe23bfed5874a0285b7.gif@48w_48h.webp",
                "tv_鄙视":"293b5d459e6264ecf314d20937a936fa672ccd1e.gif@48w_48h.webp",
                "tv_腼腆":"30984e8264324f901d19bea85dada7103b695534.gif@48w_48h.webp",
                "tv_馋":"2525c5703c594e5f0752f68db8948773caebde47.gif@48w_48h.webp",
                "tv_可爱":"f92d20f76258bc5f33fc9d7c5e2a1d41fef19a7c.gif@48w_48h.webp",
                "tv_发财":"76131e52c9b033681b4c896c6024d29ef7ec7ec2.gif@48w_48h.webp",
                "tv_生病":"beb94829fe04f1a41bd6ca611e1f6ca9ca169afa.gif@48w_48h.webp",
                "tv_流鼻血":"8ef473f74a849420da712487b2f56ecca1f695f5.gif@48w_48h.webp",
                "tv_尴尬":"e0b84ef5ee3e5b8978e584c7c5a6550c51d15f84.gif@48w_48h.webp",
                "tv_大佬":"14ca0c05382b8741940942b2430b7a8d55c02f7e.gif@48w_48h.webp",
                "tv_流泪":"7e71cde7858f0cd50d74b0264aa26db612a8a167.png@48w_48h.webp",
                "tv_冷漠":"b9cbc755c2b3ee43be07ca13de84e5b699a3f101.png@48w_48h.webp",
                "tv_皱眉":"72ccad6679fea0d14cce648b4d818e09b8ffea2d.png@48w_48h.webp",
                "tv_鬼脸":"0ffbbddf8a94d124ca2f54b360bbc04feb6bbfea.png@48w_48h.webp",
                "tv_调侃":"4bc022533ef31544ca0d72c12c808cf4a1cce3e3.png@48w_48h.webp",
                "tv_目瞪口呆":"0b8cb81a68de5d5365212c99375e7ace3e7891b7.png@48w_48h.webp",
            },

            master: "8c9b6d6637904da62d74d019cc6982de",
            friends: "0188229a9cfc284176ea9135cb9514cc",
            tagMeta: ["博主","友人","访客"],
            visitor: true // 阅读量统计
          }
        )
        new Valine(options);
        Fluid.utils.waitElementVisible('#valine .vcontent', () => {
          var imgSelector = '#valine .vcontent img:not(.vemoji)';
          Fluid.plugins.imageCaption(imgSelector);
          Fluid.plugins.fancyBox(imgSelector);
        })
      });
    });
  </script>
  <noscript>Please enable JavaScript to view the comments</noscript>


    </article>
  


          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      <!-- 文章页面 - 右侧目录 -->

  <aside class="sidebar" style="margin-left: -1rem">
    <!-- 文章页面 - 右侧目录上方 -->
<div id="toc">
  <p class="toc-header">
    <i class="iconfont icon-list"></i>
    <span>目录</span>
  </p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>



    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <!-- 博客 - 搜索框 -->
<div
  class="modal fade"
  id="modalSearch"
  tabindex="-1"
  role="dialog"
  aria-labelledby="ModalLabel"
  aria-hidden="true"
>
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">
          搜索
        </h4>
        <button
          type="button"
          id="local-search-close"
          class="close"
          data-dismiss="modal"
          aria-label="Close"
        >
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input
            type="text"
            id="local-search-input"
            class="form-control validate"
          />
          <label data-error="x" data-success="v" for="local-search-input"
            >关键词</label
          >
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
        <div class="modal fade" id="modalNotice" tabindex="-1" role="dialog" aria-hidden="true"
     style="font-family: 'Ma Shan Zheng', cursive; color: #ffffff;">
    <div class="modal-dialog modal-dialog-scrollable" role="document"
         style="font-family: 'Ma Shan Zheng', cursive;">
        <div class="modal-content" style="border-radius: 6px;">
            <!-- 公告头部 - 响应式设计 -->
            <div class="modal-header text-center"
                 style="padding: 1rem 1.5rem;border-bottom: 1px solid rgba(255,255,255,0.2)">
                <h4 class="modal-title w-100 font-weight-bold"
                    style="font-family: 'Microsoft YaHei', sans-serif;letter-spacing: 1px;text-shadow: 1px 1px 2px rgba(0,0,0,0.2);color: #ffffff;
                           font-size: 1.5rem; /* 默认PC端大小 */
                           /* 移动端适配 */
                           @media (max-width: 768px) {
                               font-size: 1.2rem;
                           }">
                    <div class="notice-title">
                        <i class="fas fa-bullhorn mr-2"> 围栏告示</i>
                    </div>
                    <small style="display: block; font-family: 'STKaiti', serif; font-size: 0.6em; color: #a0a0a0; margin-top: 3px;">
                        旧梦轻拾 · 谨识
                    </small>
                </h4>
            </div>

            <!-- 公告内容区 - 响应式设计 -->
            <div class="modal-body"
                 style="padding: 2rem; /* PC端 */
                        max-height: 70vh;
                        overflow-y: auto;
                        /* 移动端适配 */
                        @media (max-width: 768px) {
                            padding: 1rem;
                            max-height: 60vh;
                        }">
                <!-- 图片容器（响应式设计） -->
                <!--                <div class="announcement-hero"-->
                <!--                     style="margin-bottom: 2rem; /* PC端 */-->
                <!--                            /* 移动端适配 */-->
                <!--                            @media (max-width: 768px) {-->
                <!--                                margin-bottom: 1rem;-->
                <!--                            }">-->
                <!--                    <img src="http://blog.memory-life.icu/%E3%80%90%E5%93%B2%E9%A3%8E%E5%A3%81%E7%BA%B8%E3%80%91%E5%8A%A8%E6%BC%AB-%E5%A4%95%E9%98%B3%E9%93%81%E8%BD%A8.jpg"-->
                <!--                         alt="时光溯洄题图"-->
                <!--                         style="width: 100%; -->
                <!--                                max-height: 400px; /* PC端 */-->
                <!--                                object-fit: cover;-->
                <!--                                border-radius: 4px; -->
                <!--                                box-shadow: 0 2px 12px rgba(0,0,0,0.1);-->
                <!--                                /* 移动端适配 */-->
                <!--                                @media (max-width: 768px) {-->
                <!--                                    max-height: 30vh;-->
                <!--                                }"-->
                <!--                         loading="lazy">-->
                <!--                </div>-->

                <!-- 静态公告列表 - 响应式设计 -->
                <div class="announcement-list">
                    <div class="announcement-item"
                         style="margin-bottom: 2rem; /* PC端 */
                                padding: 2rem;
                                background: rgba(255,255,255,0.05);
                                border-radius: 8px;
                                /* 移动端适配 */
                                @media (max-width: 768px) {
                                    margin-bottom: 1rem;
                                    padding: 1rem;
                                }">
                        <h2 style="color: #d38532;
                                  font-weight: 600;
                                  font-size: 1.5rem; /* PC端 */
                                  margin-bottom: 1.2rem;
                                  letter-spacing: 0.5px;
                                  /* 移动端适配 */
                                  @media (max-width: 768px) {
                                      font-size: 1.2rem;
                                      margin-bottom: 1rem;
                                  }">
                            <i class="fas fa-calendar-check mr-2"></i>时光溯洄
                            <small style="display: block; font-size: 0.6em; color: #b8b8b8;text-align: right;">——
                                晨昏往事</small>
                        </h2>
                        <div style="color: #e0e0e0;
                                  line-height: 1.8; /* PC端 */
                                  font-size: 1.05rem;
                                  letter-spacing: 0.3px;
                                  /* 移动端适配 */
                                  @media (max-width: 768px) {
                                      line-height: 1.6;
                                      font-size: 0.95rem;
                                  }">
                            <!-- 内容保持不变 -->
                            <p style="margin-bottom: 1rem; text-indent: 2em;">你好。</p>
                            <!-- 其余段落内容... -->
                            <p style="margin-bottom: 1rem; text-indent: 2em;">
                                建站后的第813天，在百忙之中总算又能抽出时间来，对整个博客站点功能做整体的规划及优化完善。</p>
                            <p style="margin-bottom: 1rem; text-indent: 2em;">
                                在刚刚过去的几年时间里，往事皆以笔墨挥毫于时光素笺之上，数百天如一日，故事的书写从未间断过。</p>
                            <p style="margin-bottom: 1rem; text-indent: 2em; font-style: italic; color: #b8b8b8;">
                                时光悠悠，日月如流，过往的蹉跎岁月总在不经意间在心间回眸。</p>
                            <p style="margin-bottom: 1rem; text-indent: 2em; font-weight: 500; color: #ffffff;">
                                俯仰之间，轻舟已过万重山。</p>
                            <p style="margin-bottom: 1rem; text-indent: 2em; font-weight: 500; color: #ffffff;">
                                蹉跎之处，往事皆成云烟散。</p>
                            <p style="margin-bottom: 1rem; text-indent: 2em;">
                                这几年的时光过得太快了，好像过去这段岁月里的所有事情都发生在一瞬间。</p>
                            <p style="margin-bottom: 1rem; text-indent: 2em;">
                                这几年的时光同样太久了，久到那些时日里仿佛囊括了自己的整个前半生。</p>
                            <p style="margin-bottom: 0; text-align: right; font-size: 0.95rem; color: #a0a0a0;">——
                                八百余个昼夜，当时只道是地久天长，如今回望，不过浮光掠影间的一瞬。</p>
                        </div>
                    </div>

                    <!-- 第二个公告项 - 响应式设计 -->
                    <div class="announcement-item"
                         style="margin-bottom: 2rem; /* PC端 */
                                padding: 2rem;
                                background: rgba(255,255,255,0.05);
                                border-radius: 8px;
                                /* 移动端适配 */
                                @media (max-width: 768px) {
                                    margin-bottom: 1rem;
                                    padding: 1rem;
                                }">
                        <h2 style="color: #6cc70b;
                                  font-weight: 600;
                                  font-size: 1.5rem; /* PC端 */
                                  margin-bottom: 1.2rem;
                                  letter-spacing: 0.5px;
                                  /* 移动端适配 */
                                  @media (max-width: 768px) {
                                      font-size: 1.2rem;
                                      margin-bottom: 1rem;
                                  }">
                            <i class="fas fa-book-open mr-2"></i>墨痕新注
                            <small style="display: block; font-size: 0.6em; color: #b8b8b8;text-align: right;">——
                                待起之章</small>
                        </h2>
                        <div style="color: #e0e0e0;
                                  line-height: 1.8; /* PC端 */
                                  font-size: 1.05rem;
                                  letter-spacing: 0.3px;
                                  /* 移动端适配 */
                                  @media (max-width: 768px) {
                                      line-height: 1.6;
                                      font-size: 0.95rem;
                                  }">
                            <!-- 列表内容 - 响应式设计 -->
                            <ul style="padding-left: 1.8rem; /* PC端 */
                                      margin-bottom: 1.5rem;
                                      /* 移动端适配 */
                                      @media (max-width: 768px) {
                                          padding-left: 1.5rem;
                                          margin-bottom: 1.2rem;
                                      }">
                                <li style="margin-bottom: 0.8rem; /* PC端 */
                                         position: relative;
                                         list-style-type: none;
                                         /* 移动端适配 */
                                         @media (max-width: 768px) {
                                             margin-bottom: 0.6rem;
                                         }">
                                    <span style="position: absolute;
                                               left: -1.8rem; /* PC端 */
                                               color: #6cc70b;
                                               /* 移动端适配 */
                                               @media (max-width: 768px) {
                                                   left: -1.5rem;
                                               }">◆</span>
                                    <span style="font-weight: bolder;">溯源计划：</span>新增博文"溯源计划"，旨在用先进的数字技术留住过去的旧时光，让家族的记忆在数字云端生长发芽，全站博文数量已达90+。
                                </li>
                                <li style="margin-bottom: 0.8rem; /* PC端 */
                                         position: relative;
                                         list-style-type: none;
                                         /* 移动端适配 */
                                         @media (max-width: 768px) {
                                             margin-bottom: 0.6rem;
                                         }">
                                    <span style="position: absolute;
                                               left: -1.8rem; /* PC端 */
                                               color: #6cc70b;
                                               /* 移动端适配 */
                                               @media (max-width: 768px) {
                                                   left: -1.5rem;
                                               }">◆</span>
                                    <span style="font-weight: bolder;">围栏告示：</span>自去年夏天站点新增了“评论回复”功能后，至今时隔十余月，在芒种前夕本站久违地上线“围栏告示”功能，本公告栏会不定时更新，持续跟进记录最新站点功能调整日志，更多精彩内容请敬请期待。
                                </li>
                                <li style="margin-bottom: 0.8rem; /* PC端 */
                                         position: relative;
                                         list-style-type: none;
                                         /* 移动端适配 */
                                         @media (max-width: 768px) {
                                             margin-bottom: 0.6rem;
                                         }">
                                    <span style="position: absolute;
                                               left: -1.8rem; /* PC端 */
                                               color: #6cc70b;
                                               /* 移动端适配 */
                                               @media (max-width: 768px) {
                                                   left: -1.5rem;
                                               }">◆</span>
                                    <span style="font-weight: bolder;">图片查看：</span>最近几周时间里，考虑到图文流量费用收取问题，暂时关闭了七牛云对象存储私有空间访问权限，故博文内的图文无法正常预览，择日考虑开启访问权限。
                                </li>
                                <li style="margin-bottom: 0.8rem; /* PC端 */
                                         position: relative;
                                         list-style-type: none;
                                         /* 移动端适配 */
                                         @media (max-width: 768px) {
                                             margin-bottom: 0.6rem;
                                         }">
                                    <span style="position: absolute;
                                               left: -1.8rem; /* PC端 */
                                               color: #6cc70b;
                                               /* 移动端适配 */
                                               @media (max-width: 768px) {
                                                   left: -1.5rem;
                                               }">◆</span>
                                    <span style="font-weight: bolder;">壁纸下载：</span>后续计划实现壁纸下载功能，均为个人收集的共150+超高分辨率精美壁纸，提供在线预览以及下载功能。
                                </li>
                                <li style="margin-bottom: 0.8rem; /* PC端 */
                                         position: relative;
                                         list-style-type: none;
                                         /* 移动端适配 */
                                         @media (max-width: 768px) {
                                             margin-bottom: 0.6rem;
                                         }">
                                    <span style="position: absolute;
                                               left: -1.8rem; /* PC端 */
                                               color: #6cc70b;
                                               /* 移动端适配 */
                                               @media (max-width: 768px) {
                                                   left: -1.5rem;
                                               }">◆</span>
                                    <span style="font-weight: bolder;">阅读体验：</span>规划完善文章内分页功能，并提供“最近更新”的文章列表，计划收录更新率较高的文章，譬如：阳台日记、叙事之外、岁月如歌、游戏人生等等，尽可能多的提升在线浏览和阅读体验。
                                </li>
                                <li style="margin-bottom: 0.8rem; /* PC端 */
                                         position: relative;
                                         list-style-type: none;
                                         /* 移动端适配 */
                                         @media (max-width: 768px) {
                                             margin-bottom: 0.6rem;
                                         }">
                                    <span style="position: absolute;
                                               left: -1.8rem; /* PC端 */
                                               color: #6cc70b;
                                               /* 移动端适配 */
                                               @media (max-width: 768px) {
                                                   left: -1.5rem;
                                               }">◆</span>
                                    <span style="font-weight: bolder;">友链完善：</span>持续优化完善友链页面，整理归档个人常用的高质量网站合集，无偿分享给有缘人。
                                </li>
                                <li style="margin-bottom: 0.8rem; /* PC端 */
                                         position: relative;
                                         list-style-type: none;
                                         /* 移动端适配 */
                                         @media (max-width: 768px) {
                                             margin-bottom: 0.6rem;
                                         }">
                                    <span style="position: absolute;
                                               left: -1.8rem; /* PC端 */
                                               color: #6cc70b;
                                               /* 移动端适配 */
                                               @media (max-width: 768px) {
                                                   left: -1.5rem;
                                               }">◆</span>
                                    <span style="font-weight: bolder;">音乐餐厅：</span>历经十余小时不间断调研和尝试，本站成功上线”音乐餐厅”功能，目前仅收录了个人在QQ音乐平台积累的两份歌单，再匆忙也要记得点播一首喜欢的音乐，没有音乐熏陶的心灵终究是充满缺憾的。
                                </li>
                                <li style="margin-bottom: 0.8rem; /* PC端 */
                                         position: relative;
                                         list-style-type: none;
                                         /* 移动端适配 */
                                         @media (max-width: 768px) {
                                             margin-bottom: 0.6rem;
                                         }">
                                    <span style="position: absolute;
                                               left: -1.8rem; /* PC端 */
                                               color: #6cc70b;
                                               /* 移动端适配 */
                                               @media (max-width: 768px) {
                                                   left: -1.5rem;
                                               }">◆</span>
                                    <span style="font-weight: bolder;">三言两语：</span>每张照片都是时光的便签，随手一贴就记下了那天，本站结合Mamos实现并注入留言板功能，随缘记录那些藏在照片背后的故事。
                                </li>
                                <li style="margin-bottom: 0.8rem; /* PC端 */
                                         position: relative;
                                         list-style-type: none;
                                         /* 移动端适配 */
                                         @media (max-width: 768px) {
                                             margin-bottom: 0.6rem;
                                         }">
                                    <span style="position: absolute;
                                               left: -1.8rem; /* PC端 */
                                               color: #6cc70b;
                                               /* 移动端适配 */
                                               @media (max-width: 768px) {
                                                   left: -1.5rem;
                                               }">◆</span>
                                    <span style="font-weight: bolder;">旧梦轻拾：</span>更新全站博客文章所属分类，共设有代码锋芒、部署之道、旧梦轻拾、人间片刻等十余种分类。
                                </li>
                                <li style="margin-bottom: 0.8rem; /* PC端 */
                                         position: relative;
                                         list-style-type: none;
                                         /* 移动端适配 */
                                         @media (max-width: 768px) {
                                             margin-bottom: 0.6rem;
                                         }">
                                    <span style="position: absolute;
                                               left: -1.8rem; /* PC端 */
                                               color: #6cc70b;
                                               /* 移动端适配 */
                                               @media (max-width: 768px) {
                                                   left: -1.5rem;
                                               }">◆</span>
                                    <span style="font-weight: bolder;">方寸之间：</span>博客应用版发布，更便捷的阅读体验来了！现已正式推出独立的桌面应用程序与移动端应用程序，暂时通过网盘和代码库提供安装包。
                                </li>
                                <p style="margin-bottom: 0; text-align: right; font-size: 0.9rem; color: #8a8a8a;">
                                    此公告最后更新于：<span style="color: #6cc70b;">2025/09/30晚</span>
                                </p>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 公告页脚 - 响应式设计 -->
            <div class="modal-footer"
                 style="border-top: 1px solid rgba(255,255,255,0.2);
                        padding: 1rem 1.5rem; /* PC端 */
                        justify-content: space-between;
                        /* 移动端适配 */
                        @media (max-width: 768px) {
                            padding: 0.8rem;
                        }">
                <small style="color: #ffffff;
                            font-size: 0.9rem; /* PC端 */
                            /* 移动端适配 */
                            @media (max-width: 768px) {
                                font-size: 0.8rem;
                            }">
                    <i class="iconfont icon-pen"></i>
                    <i class="fas fa-info-circle mr-1"></i>芒种前夕 · 旅途第813天
                    · 2025/05/28
                </small>
                <button id="confirm-btn" type="button" class="btn btn-sm" data-dismiss="modal"
                        style="background: #a0a0a0;
                               color: #ffffff;
                               border-radius: 4px;
                               padding: 0.5rem 1.2rem; /* PC端 */
                               border: none;
                               font-size: 0.9rem;
                               /* 移动端适配 */
                               @media (max-width: 768px) {
                                   padding: 0.3rem 0.8rem;
                                   font-size: 0.85rem;
                               }">
                    <i class="fas fa-check mr-1" style="color: #ffffff;">心已阅</i>
                </button>
            </div>
        </div>
    </div>
</div>

<style>
  .notice-title {
    display: flex;
    align-items: center;
    white-space: nowrap;
  }

  .notice-title:before,
  .notice-title:after {
    content: "";
    flex: 1;
    height: 1px;
    background: #ddd; /* 横线颜色 */
    margin: 0 10px; /* 横线与文字的间距 */
  }
</style>


<style>
  /* 响应式模态框宽度 */
  @media (min-width: 992px) {
    #modalNotice .modal-dialog {
      max-width: 800px;
    }
  }

  @media (max-width: 991px) {
    #modalNotice .modal-dialog {
      margin: 0.5rem auto;
    }
  }
</style>

<script>
  // 页面加载完成后执行
  document.addEventListener('DOMContentLoaded', function () {
    // 检查是否首次访问
    if (!localStorage.getItem('hasShownPopup')) {
      // 动态加载notice.ejs内容
      fetch('_partials/notice.ejs')  // 替换为实际路径
        .then(response => response.text())
        .then(html => {
          // 插入到页面body末尾
          document.body.insertAdjacentHTML('beforeend', html);

          // 手动初始化Bootstrap模态框
          $('#modalNotice').modal('show');

          // 标记为已显示
          localStorage.setItem('hasShownPopup', 'true');

          // 监听关闭事件
          $('#modalNotice').on('hidden.bs.modal', function () {
            // 可选的后续处理
          });
        })
        .catch(error => {
          console.error('加载公告栏失败:', error);
          // 备用方案：显示简单弹窗
          const fallbackHTML = `
                <div class="modal-backdrop" style="/* 样式 */">
                    <div class="modal-content">/* 内容 */</div>
                </div>`;
          document.body.insertAdjacentHTML('beforeend', fallbackHTML);
        });
    }
  });
</script>

    

    
  </main>

  <footer>
    <!-- 博客 - 页脚 -->
<div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.fluid-dev.com/docs/guide/" target="_blank" rel="nofollow noopener"> <span>Memory | 个人文档站点</span> </a>
<i class="iconfont icon-love"></i> <a href="https://hexo.fluid-dev.com/docs/guide/" target="_blank" rel="nofollow noopener"> <span>配置指南 | Hexo Fluid 用户手册</span> </a> 
    </div>
  

  

  
    <!-- 备案信 ICP for China -->
    <div class="beian">
  <span>
    <a href="http://beian.miit.gov.cn/" target="_blank" rel="nofollow noopener">
      京ICP证123456号
    </a>
  </span>
  
    
      <span>
        <a
          href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=12345678"
          rel="nofollow noopener"
          class="beian-police"
          target="_blank"
        >
          
            <span style="visibility: hidden; width: 0">|</span>
            <img src="/blog/img/police_beian.png" alt="police-icon"/>
          
          <span>京公网安备12345678号</span>
        </a>
      </span>
    
  
</div>

  

  

</div>

<!-- 评论框美化 -->
<style>
    #comments .veditor{
        min-height: 20vh;
        background-image: url(http://blog.memory-life.icu/pathway0716.jpg);
        background-size: contain;
        background-repeat: no-repeat;
        background-position: right;
        background-color: rgba(255,255,255,0);
        resize: none;}
</style>

<script>
    //   自定义邮箱审核规则
    document.body.addEventListener('click', function(e) {
        if (e.target.classList.contains('vsubmit')) {
            const email = document.querySelector('input[type=email]');
            const nick = document.querySelector('input[name=nick]');
            const reg = /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
            if (!email.value || !nick.value || !reg.test(email.value)) {
                const str = `<div class="valert text-center"><div class="vtext">请填写正确的昵称和邮箱！</div></div>`;
                const vmark = document.querySelector('.vmark');
                vmark.innerHTML = str;
                vmark.style.display = 'block';
                setTimeout(function() {
                    vmark.style.display = 'none';
                    vmark.innerHTML = '';
                }, 2500);
            }
        }
    })
</script>



  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/blog/js/events.js" ></script>
<script  src="/blog/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>







  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/blog/js/local-search.js" ></script>

  <script defer src="/blog/js/leancloud.js" ></script>




    
<script src="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>



<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/blog/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
